Knowledgebase

Run AJAX in the background

Posted by HostSentry, 09-21-2007, 08:10 PM
It's pretty frustrating that the page pauses while downloading ajax content. Is there any way around this? Using iframes I can accomplish what I want, but it's still frustrating to not be able to do it entirely with ajax. While you wait to get the content animated gif's pause, and the page is generally unusable. This is even true if you execute it onload for the body.

Posted by Tom P, 09-21-2007, 08:30 PM
Hey HostSentry, there are various ways to try and speed up Ajax requests. For instance when you get the content, it helps if it has already been generated server side first. So an idea might be to use page caching (as long as it's not too dynamic). A good practice is when the page is first loaded, to have all the content that is needed done that that time. It adds extra delays if the client has to get the page and then go off to get the content. Ajax should only be used to get content without having to reload the page, if it can be all sent at once then it should be.

Posted by justforselling1, 09-22-2007, 01:59 PM
If you are talking about the page initial load that takes longer, try using the defer=true option inside the script tag. That makes Ajax run after the page displays If you are talking about the contents of a div or part of the page while is gathered, remember that Ajax is for small contents, you are trying to get a too long text string. The trick I used here is to load the contents in a hidden div and once I have it, then I do update the visible div using javascript (the trigger is the event onpropertychange from the hidden div and when it fires I copy the innerHTML from that one to the visible div)

Posted by HostSentry, 09-22-2007, 02:04 PM
The problem is that the page I am requesting takes about a half a second to process. So while it waits for that very small response, the browser freezes. All of this is after the initial page load. No big deal, I worked out a solution with iframes.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
JodoHost Down or Gone? (Views: 595)


Language:

Client Login

Email

Password

Remember Me

Search