0

I have a bunch of AJAX requests, the first is a

$.post("go.php", { url: pastedURL, key: offskey, mo: 'inward', id: exID});

This request, in go.php includes a system command, which despite nohup and & at the end, doesn't stop whirling on Firebug - waiting for response.

Unfortunately, the next AJAX request

$.post("requestor.php", { request: 'getProgress', key: offskey}, function(data) { console.log(data.response); }, "json");

Doesn't run, it whirls round in firebug (i'm guessing until go.php has finished) - it overloads everything eventually (this is on a timer to check every few seconds).

So I guess the question is, is there an AJAX method which simply throws data and walks away, instead of waiting for response... or someway I can perform another request whilst the other is waiting.

Hope someone knows what I mean.

waxical
  • 3,616
  • 7
  • 40
  • 66

3 Answers3

1

Check for async: false, as parameter for $.ajax() method in jQuery.

You need it to be set async: true.

devdRew
  • 4,147
  • 2
  • 21
  • 32
1

Turns out the PHP request on the other end would need this in order to proceed with waiting:-

"> /dev/null 2>/dev/null &"

source

Community
  • 1
  • 1
waxical
  • 3,616
  • 7
  • 40
  • 66
0

There are a limited number of connections used by the browser. The number varies by browser, but for older ones like IE7 it can be as little as 2 connections per server. Once you fill them with pending requests you have to wait for those to complete before you can make any additional requests to that server.

(this is on a timer to check every few seconds)

It sounds like you may be making additional requestor.php requests using setTimeout or setInterval before the previous ones have finished? If so, don't do that. Use a full $.ajax (perhaps with a timeout as well) and in the success/error callback only then make another request.

Dave Methvin
  • 1,408
  • 10
  • 12