I am trying to make sure my Ajax does not send another request before it receives a reply. To the best of my knowledge the code I will post is supposed to do this but I am still getting a -1 for $return.The ajax request repeatedly gets the echoed value of a function which is using a bat file to get the size of a file that is being uploaded via FTP. The application using this shifted storage and is now in UNC path and now the Ajax gets nothing in return. If I run the bat file manually I can get a response, but it might take 1 second or it might take a minute, for some reason there doesn't seem to be a lot in the middle. If I use the PHP script to call it I get $out equal to an empty array and $return equal to -1. My guess is that it's taking so long to process the request the Ajax requests are interrupting each other.Ajax:I am using ajaxTime to try and see how long the requests are taking. They are varying from usually around 550-650 response time:var ajaxTime = new Date().getTime();getdSize(f, ajaxTime);function getSize(f, ajaxTime){        $.ajax({            url: php file handling the ajax request,            type: POST,            data: {                file : encodeURIComponent(f),                }            })        .done(function(data){            var totalTime = new Date().getTime()-ajaxTime;            console.log(Ajax Time:  + totalTime);            console.log(Data:  + data);        })        .fail(function(data){            if ( data.responseCode ){              console.log( data.responseCode );            }            console.log(Ajax failure);        });    }PHP:    $file = $_POST['file'];    echo bat_getSize($file);[this calls bat_getSize function]function bat_getSize($file){    exec(getSize \$file\,$out, $ret);    return $out[0];}Which calls this bat code:@echo offecho %~z1
Ajax Done Callback to prevent requests from interrupting each other
javascript;php;jquery;ajax;batch