Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,206,043 members, 7,994,537 topics. Date: Tuesday, 05 November 2024 at 03:19 PM |
Nairaland Forum / Science/Technology / Webmasters / Ajax/jscript Help (882 Views)
Need A Designer To Do Some Jscript And CSS / Dhtml Pastebin / Codebin : Run Php/jscript/html Online / Form Validation Tutorial Using Javascript, Php And Ajax! (2) (3) (4)
Ajax/jscript Help by cmon(m): 12:24am On Oct 26, 2009 |
I will like the js below to be able to display a loading, indication to alert the user that the page is loading. As I'm not an expert in this field, can you please modify it to function like that. It will be cool if the loading indicator can include a gif animator with filename loading.gif. I'll deeply appreciate your help. The code of the .js file follows;
|
Re: Ajax/jscript Help by yawatide(f): 9:56am On Oct 26, 2009 |
Off the top of my head (these days, I don't write ajax code anymore. I simply use a jquery plugin so my brain had been dumbed down quite a bit ): I blv the "loading" state in ajax is "3" (readyState == 3). So when you are checking for the readystate, if it is 3, you set your loading.gif to display: block. when it is 4, you set it to display: none. I am pretty sure if you googled for it, you will find perhaps a more elegant solution. good luck! |
Re: Ajax/jscript Help by kolitos007: 2:52pm On Oct 26, 2009 |
Yep, I think what yawa said is correct, ready state 3, make note of this; 0: not initialized. 1: connection established. 2: request received. 3: answer in process. 4: finished. Other option is to have loading in your div, that is the simplest way, but that is for the first time you loading just have <div id=''>Loading Page</div> Alot of answers to your question on line, just google it you will find it, or just create to functions in yoru js function ShowLoading() { document.getElementById("Loadmsg".style.display = "block"; } function CloseLoadingMsg() { document.getElementById("Loadmsg".style.display = "none"; } The first function before this line var page_request = false then the function before this line if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http"==-1)) but to be honest I would change it to this if (request.readyState == 4) { CloseLoading(); if (request.status == 200 || request.status == 304) { } } And make sure you have the div for theloading page set, hope this helps. |
Re: Ajax/jscript Help by Nobody: 4:16pm On Oct 26, 2009 |
come to think of it, i seem to have forgotten how to use raw ajax like that. I will rather use jQuery or my dhtmlExt library. But for newbies, i think jquery is better. However if you are tryin to learn ajax, try www.javascriptkit.com - that was where i started learning ajax |
Re: Ajax/jscript Help by kolitos007: 4:21pm On Oct 26, 2009 |
*dhtml: Yeah you are right, jquery is the easy way out, but I think the raw data gives you more, I use raw ajax so I can manipulate my data. its good if your result can give different conditions. But to behonest, it works better in .net because visual studio provides script for you to use. |
Re: Ajax/jscript Help by Nobody: 11:41pm On Oct 26, 2009 |
i used the raw jscript to build my library which is somewhat easier than jquery. all these for instance will be: if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http"==-1)) document.getElementById(containerid).innerHTML=page_request.responseText } $.post("result.php?user=43",function(response) {$('#containerid').html(response)},function() {alert("An error occured"}); that is one of the functions in my javascript library, it is similar to the jquery $.ajax which is somewhat more complicated but more functional with timeouts and all that which i have conveniently ignored. You need to use libraries to speed up so you dont spend forever on a project. Even with that, i am still way strugglin to meet up with deadlines. These days i take the easiest way out o my broda, at least till i clear my desk which is rather full at this time |
(1) (Reply)
Join My Team And Earn Over #200,000 Every Month / What's Wrong With This Php Form Code Sef? / Path To Truth
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 32 |