2

I have a highly ajax run website where everything is running smooth as butter except one specific Ajax call. After a random number of calls it seems to never return. It's not a caching issue because I've turned off caching with $ajax.Setup and it also happens randomly, not just after the first call. Once it happens though, it will not work again until I refresh the page. I've confirmed it has nothing to do with the script on the server as I for testing purposes I just had it return immediately.

The only thing that is unique about this call is I pass a rather sizable json object that is dynamically created. I'm wondering if there is an error in the construction of the json object, though I kind of doubt it because I believe the same JSON object can be passed once and work and than passed again and not. So, my only theory at this point is it is my longest ajax call and calling it multiple times is just overloading some server threshold. Does anyone know anything about this? I'm running PHP and IIS.

Here is the simple code I use:

$.post("<?=$_SERVER['PHP_SELF']?>?ajax=editType", {id1: id1, id2: id2, json: jsonString}, function(data) {
    console.log(data);                  
}, "html").error(function(xhr, status, error) {
    alert("Error: " + status);
});

the json string is:

{"0":{"part_type_column_id":"526","displayable_name":"Fourth","column_number":1,"default_visible":"on","datatype":"Radio Button","value_options":"First Radio,Second Radio,Third Radio,Fourth Radio,Fifth Radio"},"1":{"part_type_column_id":"525","displayable_name":"Fifthd","column_number":2,"default_visible":"on","datatype":"Checkbox"},"2":{"displayable_name":"asdf","column_number":3,"default_visible":"on","datatype":"Text"}}

If I keep sending this ajax call after it doesn't immediately return, it will stop all ajax on the site until it times out. After seeming to take forever, it will time out and finally just alerts "error".

Any idea why this could be happening? All I can think of is some kind of max transfer limit being reached.

4

3 に答える 3

1

You're not echoing out $_SERVER['PHP_SELF']. Your tag needs to be changed to either call echo, or just use the

于 2012-08-14T22:24:50.480 に答える
1

you are don't printing the variable $_SERVER['PHP_SELF']. uses

<?=$_SERVER['PHP_SELF']?> 
or
<? echo $_SERVER['PHP_SELF']?> 
于 2012-08-14T22:56:50.613 に答える
1

I had the same problem few days back. In my case return code was 0. There are two cases for such type of problems. 1. If you are making an cross-domain call and browser rejects your ajax. And 2. If there is a problem at your server side which is not allowing your ajax to execute and drop connection immediately.

My case was 2nd. I was running a Demon on my server which was monitoring every calls on the server. This demon was dropping my particular ajax calls before even connection was established. I stopped it and then that particular ajax started working again. I wonder if it is the same cause in your case as well.

Thanks.

于 2013-06-27T07:00:11.750 に答える