Reputation: 44256
Ok, this isn't a problem with timeouts. I took out all the expensive parts of the PHP script, and made it just output [1,2,3]
, so that it won't timeout. Still doesn't work, so clearly I'm doing something really braindead.
The whole thing:
sparql_url = "http://royiv.dyndns-ip.com/websci/git/clean_payroll_json.php";
function foo(response)
{
alert("foo called.");
alert(response);
hers = response["DOE, JANE"];
alert(hers);
}
function bar(request, stat, err)
{
alert("Something messed up.");
alert(err);
}
$.ajax({
url: sparql_url,
dataType: 'json',
error: bar,
success: foo,
timeout: 20 * 1000
});
Output is "foo called", "null", and then the JS is terminated.
Viewing the transfer in Wirshark shows the response is sent. Firebug does not show anything in the "Response" tab, but shows a Content-Length of 7.
I'm having a weird timeout issue with jQuery. After 10 seconds, something is terminating the request, but I'm not sure what. As I watch the HTTP request in Wireshark, at just about 10 seconds, Firefox starts sending RST to the server, closing the connection. Here is how I'm performing the request:
$.ajax({
url: sparql_url,
error: bar,
success: foo,
timeout: 20 * 1000
});
After the timeout, foo
, the success function, is being called, not the error callback. This makes me think jQuery isn't doing it, but I'm not sure here. What's going on here? (The URL is slow, but it is actually responding at just about 10 seconds. It is sending back JSON data.)
Upvotes: 2
Views: 193
Reputation: 11719
Can you inspect the response data with wireshark? If the response is empty, there is something wrong with the php script. Maybe the php script produces an empty response if it is called by javascript (missing some http header like user agent, language, encoding, ...).
just a guess...
Upvotes: 0
Reputation: 996
In your phpscript set the "Content-Type" header to application/json instead of text/html.
Upvotes: 2