Can I Make My DOM Script Asynchronous? (Not AJAX...)
Oct 7, 2006
I've got a script that, onload, loops through every tag on the page (getElementsByTagName ('*')) and can be pretty slow on some of my pages with MANY tags.
What I'm wondering is if there's some way I can tell the browser to run the script asynchronously, without locking up the browser while it loops through all the tags and adds its objects and properties to them?
I'm pretty sure I've made the script about as effecient as possible. There's just no way around checking all the tags.
I want to send another ajax request when one request is in process to get the status of first request. If I call both the request the second request gets blocked till the completion of the first request.
I want to make a page which loads the div's with ajax The html code of the page is
Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> //styles and other script code <script language="javascript" src="../js/intro.js"></script> </script> [Code]....
Now the problem is that javascript "freezes" and setInterval does not work.. Is there any solution to load the files order such i have it in code one-by-one and run the message function?
I'm having (once again) tremendous problems with IE (7), trying to create an application that behaves properly.
This time, it's with Ajax calls triggered by a button click, which do not behave asynchronously.
Here is the highlight of what I'm trying to achieve: a button clicked sends an ajax call to the server whilst the call is made and until the callback function has returned (or an error has been identified), a "wait" animation is triggered. (in the case below, simulated by appending a status in a div)
To achieve this, I decide to use .ajaxStart(), .ajaxStop() and .ajaxError() to trigger the wait animation. It works perfectly in FF and Chrome, but (as usual) not in IE. In IE, when I press the button, the button remains depressed until the ajax call is finished, and then all statuses are dumped at once onto screen. Not very asynchronous...
Here is my code:
If I uncomment line 11 and uncomment the alert, it seems that this forces IE to do things in the proper order. Obviously that's not a solution however...
Will I have to (once again) write IE-specific code to get things working properly?
I am using AJAX and coldfusion, and am having trouble getting some alerts to work. I am using the http object in javascript: var url="add_item.cfm" oXmlHttpadditem=GetHttpObject(addStateChanged); oXmlHttpadditem.open("GET",url,true); oXmlHttpadditem.send(null);
then, in add_item.cfm, I am just using: <script type="text/javascript">window.alert("Hello World ");</script>
but the alert isn't being displayed. I assume this has to do with client-side/server-side issues, but can someone please clarify why this doesn't work, and perhaps offer a fix or alternative solution?
I think it's okay to ask this question in this group, but if not please point me to the correct one!
How does one go about doing asynchronous updates between two web clients? Take Google Chat for example... how does Google Chat update a chatter's chat window with text entered by the other chatter?
I'm trying to get a return boolean or something I could use to then do another asynchronous request have my first has completely finished.
I'm messing around with Javascript on this basic PHP blog I built and I have a table of articles and one of the table columns is published/unpublished. I'm trying to have when they click the icon it will connect to MySQL, update the current row with new publish value (opposite of current) then refresh the div id element that the publish/unpublish icon is in to reveal the new status. I built a class for my javascript requests so most values are stored in global properties.
I think what I'm coming across is when I click the icon it updates the table but before that onreadystatechange can hit 4 my request for the new content is going through so the request url I'm using as well as the return div id for the responseText are getting mixed up between trying to do a sql update, loading the responseText in "message" then trying to sql query for the new results and loading that responseText in "content".
I need to create a callback for a line of code that performs asynchronous work so that another a line of code can be called after it is finished. I've found a number of webpages that attempt to show how this can be done with two functions, one calling the other in Russian-doll fashion, but I can't see how to do it with my code.It takes the URL of a sound file, redefines a previously defined embed to point at that sound file, and then plays it. The problem is that I lose focus on the documentElement that was selected before the playIt() function is called. So in the playIt() function I save the focused element in a variable and focus() it after the embed-switcheroo and autoplay is performed. This doesn't work, because the "e.parentNode.replaceChild(clone, e);" is performed asynchronously; when it finishes, it clears the focus in the document (internal id's have changed? Reason unknown.) So I need the focus() code to follow the replaceChild() code. I want to accomplish this by having the focus() code execute as a callback following the replaceChild() code. How would I break this into two procedures, one calling the other, reproducing a synchronous flow?
I'd like to process several blocks of parallel actions, but in a sequential manner.
As an example:
Thus, I want to process blocks, from which I don't know how long they will take and afterwards have a couple of actions, before beginning with another block. I already tried it through using .queue, .ready() etc, but that leads to very ugly or unusable code..
Can I do the following without my program crashing? [code]...
I have created an application that does something similar to the code I just posted. However, my program crashes intermittently. Sometimes it will crash after calling jQuery.get() a few times (with several http requests still pending). Other times it will get through all of them just fine.
I want to know if Ajax can handle that many asynchronous requests without crashing? Can someone look at this to see if there is something I am missing?
Im trying to use jquery to try to do what the image shows: Its for a website made for iphone so im trying to add the slide effect. It all seems a little complicated, but ill explain: 1-The user clicks a link 2-A loading message (or image) appears Meanwhile, the new page loads on a hidden side (its a FULL page, not just a div)
I am building a library of functions which call this function, so I cannot have the data processing done within the success function, I need to extract the data itself.
I have some trouble with my app. User enters his login&pass, they are being checked on server using ajax, and if they're ok, i wanna open new page, which'll set cookies and session vars, but i have an universal script, and I need request something like universalScript?mode=login (mode is GET) and some POST parameters such as login and pass, besides it must be new page, not ajax, Some ideas?
Anyone loading a bunch of CSS or Javascript via <link> tags on a web page knows about "blocking": where the browser stops the loading of the page because it has to go fetch (and read/parse) an external file. If you have a lot of these, or even if you don't and the user has a slow connection, you have a slow page. Users hateses teh slow pages, hatses them.
At the 2010 Fronteers Conference, Stoyan Stefanov gave a talk on Progressive Downloads and Rendering, where he listed some tricks to get around blocking by Javascript or other external files to make page load speed up. One trick was adding a <script> tag in the body (near the bottom, so after the important stuff has loaded) which adds a <script> tag to the <head> dynamically and runs it. While that file is being fetched, the rest of the page can continue to load. This is a bit asynchronous, isn't it (similar to web pages still loading content while also fetching images)?
As a follow-up to his Higher Order Javascript article (see SitePoint thread about it), Piers Cawley has gone further with Asynchronous Streams, where he uses jQuery (as an example) to load external files asynchronously to avoid blocking of the HTML document loading. In my web development career I haven't worried about blocking, but plenty of folks around here are loading ginormous files, and lots of them, for large sites. As developers, what do you do to get around slow page loads? Have you done anything like this asynchronous calling of the external files?
I am trying to use jQuery's AJAX functionality to make a progress bar. A request is submited via AJAX, which starts importing data to a database. Once submited another AJAX request is called on an interval which checks the progress of this import, a progress meter is then updated using this information. However, the progress AJAX call which is fired on the submit of the form only returns once the import has complete. Its like its being blocked by the initial request? How I can get both calls to work at the same time?
I am working on a search function to call some data from an XML document. It works fine except for the fact that it's case sensitive.
What method do I need to use from the String object to make it case insensitive, so that a J is the same as j?
I was thinking of changing my text box string to all lower case using toLowerCase(). If I did this, then would I have to do the same thing in the info retrieved from the XML document? I want to make it so that Tom is the same as tom - I'm just wondering where I would have to apply these - to both the XML doc (being read for the output) as well as the text box string (the input).
Just wondering if I'm overthinking this, or on the right track with toLowerCase().
Also, in my search, to filter the results from only entering a few letters (not the entire element, I'm using the substr() method. It seems to work but I don't know if this affecting the case somehow...