http://jsfiddle.net/rpflorence/NF2jz/187/
Are you saying you want the browser to do everything it normally does when you load a new page (ie Safari, the address field starts filling up with a blue status bar, other browser have a spinner somewhere in the interface.)
If so, no, there's no direct way to do that. I guess onRequest you could create an iframe and point it to some page on your server that has a ridiculously long sleep time so the browser is always trying to load it, then onSuccess of the ajax request you could destroy the iframe. I don't kow ... seems silly. If you're reloading the whole page with ajax, and want it to feel like it's not ajax, why not just reload the whole page?
If I understand correctly you have multiple requests firing that replace most of the content on the page? Then I would guess you would to create and display a spinner and then have some way to figure out when the last request has completed and remove the spinner.
I had to log in to facebook for the first time in forever to see what your'e talking about.
Facebook either has a little indicator next to the link you clicked (which is completely sufficient user feedback), or, in the case of moving to a user's profile, it reloads the whole page.
But facebook doesn't try to act like it's reloading the whole page when it's not.
But there's your solution, as I mentioned before, just create an iframe and load something that will never finish loading, then kill it when the request is complete. I still don't think it's worth the extra request and extra code, but that's your decision.
> Is this email group about helping eachother and producing solutions to
> problems or just about forcefully trying to prove the one who asked a
> question is stupid?
If David Walsh is asking the question, yes, the point is to prove the asker is stupid. Otherwise, no, it's about helping people come to solutions.
Sorry, most the time I'm busy at work and so I just type quick emails to try to help out. The directness isn't meant to be rude, just quick.
However, that brings up a valid point about what types of solutions we're going to suggest. I have a hard time offering up a hack as a solution and would rather find out the real problem and then help somebody implement a real solution--not just what they think is the solution.
Before you get all frustrated with responses that aren't what you expect, keep in mind that a lot of the people on this group are professional web developers, people working on high profile sites like monster energy, visa, mtv, enterprise apps like cloudera's stuff, etc. So when they say "sounds like you're doing something wrong" don't forget where the advice is coming from. That's the best part about being involved with open source, interfacing with arguably some of the best developers out there. Without the help of people on this list I'd probably still be doing sites for http://nealthebarber.com (best site evar!)
And please remember, just because it sounds rude doesn't mean it is. It's email, it can always sound rude :)
-Aaron
Sorry for any typos. Big fingers , tiny buttons.
If I was forced to code it I would have the request be a normal request and then add onRequest and onComplete events.
onRequest I'd create an iframe element with a src pointing to a file, that, on the server side (assuming php) is just a big long sleep(), like sleep(10000000000). That should force the browser into a "loading state".
And then onComplete destroy the iframe element.
I love to beat dead horses. A simple indicator by the link or over the content that's updating is enough ...
Hmm, yes, but consuming resources on the server, and IIRC if the
connection is severed at the client end, they won't be freed until
min(your_sleep_period,max_exec_time).
I think you'd be better off trickling bytes to the client way outside
of your HTTPD, so you don't tax your server proper at all. Something
like a tarpit daemon. I still think this whole idea is pretty strange,
though.
-- S.
Momentary lapse of reason...
Sent from my iPhone