Hi, I'm new to this forum so sorry if this maybe in the wrong section for some reason.

Basically, what I am trying to do is call several ajax requests using jQuery on the same page, i know that all browsers are capable of requesting multiple requests. However in Chrome and Safari my website works fine, but IE, Firefox and Opera all only call the first request then dont call, the second two. I dont know why though?

All of the code for the site is here: http://daily.adamscarter.co.uk/

Thanks in advance! :)

Recommended Answers

All 5 Replies

Adam_C,

I have a theory on this issue.

I reckon that all the major browsers can in theory handle multiple, simultaneous AJAX requests but the different javascript engines compete for motherboard resources in different ways to make multiple requests fail in some cases. If I recall correctly, I answered a very similar question here on Daniweb very recently and in that case it was Opera/Safari that had the problem, while FF/IE/(Chrome?) were OK. So it appears to be a question of the interaction between the various browsers and particular hardware. Well, that's my theory anyway.

You may not like the solution because your code appears to be not particularly suitable for the conversion (I hope I'm wrong). You have to ensure that simultaneous ajax requests are never made. Instead, make the requests in cascade, such that the completion phase of each ajax function, makes the next request in the sequence.

I have in mind a general purpose AJAX cascade function (jquery plugin?) but simply haven't found the time to write it. In first (mental) draft it involves a stack (javascript Array) of XHRs which are set all up but not sent. The completion phase of each .ajax, will check to see if there's anything else in the stack, pop/shift the next XHR off the stack and send it. A variant idea is to somehow allow the data received from each call to determine the data sent in subsequent call(s) (tricky).

You could write this sort of thing yourself or you should be able to hard code specific sequence(s) (easier but less flexible). Hard coding ajax cascade is not at all tricky so long as the sequence is known and doesn't vary.

Airshow

thanks for the tips guys, will try the jQuery plugin tomorrow, as for your idea Airshow it seems another level above my coding abilities. I'm fairly new to javascript even though I have been using its cousin AS2 in Flash, and I have only been using jQuery for literally a few weeks. I'll see what I can do with all feedback though, appreciate it! :)

Adam_C,

Take a look at AleMonteiro's suggestion - nice one, which I was not aware of.

It seems to be similar to my idea for a general purpose function, though it apperars to employ delays, rather than a cascade.

Airshow

Hi, i seem to be having a bit of trouble with this plugin, could anyone provide an example code of how to use it please? I would be very grateful ! :)

p.s if it helps im using jquery version 1.4.4 (uncompressed)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.