Slater Tyranus Slater Tyranus - 10 months ago 71
Javascript Question

Javascript blocking on post request

I have, what I believe to be a pretty normal and sane javascript function, below:

$scope.pickFile = function() {
function(Blob) { // OnSuccess
var uuid = Blob.url.split('/').slice(-1)[0];
window.location.replace("/url" + uuid);
"/other_url" + uuid,
{'input': $('#rawText')[0].checked? "text" : "features"}

Now, the bizarre thing is that the redirect doesn't happen until the post request finishes. My gut says this might be some magic happening behind the scenes with filepicker, but I have no idea what it might be, and there doesn't seem to be any documentation around it.

It doesn't seem to be simple synchronicity either since the redirect is actually first, but it is blocking on the post request completing.


Try to change the post to explicitly not include the callback handler:

var mypost = $.ajax({
  type: "POST",
  url:  "/other_url" + uuid,
  data:  {'input': $('#rawText')[0].checked? "text" : "features"}
return false;