Jquery ajax with asynchronous false freeze firefox

I have code that calls $ .ajax as follows:

$.ajax({

                        type: "POST",
                        url: "/sandbox/graphloader/mock3",
                        async: false,
                        data: {calInput1:dates[0], calInput2:dates[1]},
                        success: function(data){
                            data=eval(data);
                            for(var x in data[0]){
                                //alert(data[0][x]);
                                //fill columns here;
                            }

                            fillPercents(column);
                        }});

Now it works in all browsers except Firefox. firebug indicates that it receives a response from the message, but for some unknown error, it does not display data. What could be the problem?

+3
source share
3 answers

This is design behavior.

Never use async: false.
Because Javascript runs in the user interface thread, the request async: falseblocks the browser until the server responds.

+10
source

, "", . error: function(jqXHR, textStatus, errorThrown){} . async: false .

+1

columns AJAX.

console.log, , - , .


, , .

:

var lastRequest = 0;   //You may want to put this in a namespace or closure

...

var thisRequest = ++lastRequest;
$.ajax({
    type: "POST",
    url: "/sandbox/graphloader/mock3",
    async: false,
    data: {calInput1:dates[0], calInput2:dates[1]},
    success: function(data){
        if (thisRequest !== lastRequest) return;
        ...
    }});

thisRequest.
.

0

All Articles