0

I'm using jQuerys AJAX functionality to send data to the server as posted below

var updateTLC = $.ajax({
        url : resourceUrl + "/update",
        type: 'POST',
        data : data,
        cache : false,
        dataType : 'json',
        //async : false    
    });

    updateTLC.done(function(data) {
        if (data.success) {
            successCallback(data)
        }
    });

    updateTLC.fail(function (data, status, error) {
        failCallback(data, status, error);
    });

My problem is that the function that is called after this is executed before it gets to updateTLC.done. This only happens on Firefox (vers 42), it works fine in Chrome and Edge.

If I use async:false it also works in Firefox. Using async:false is not the worst option here as the following function loads another page. At the moment it loads the page without the data I need.

Appreciate any advice on this

alan oreilly
  • 69
  • 2
  • 7
  • "the function that is called after this" — What function is that? – Quentin Nov 26 '15 at 11:24
  • "the following function loads another page" — Why are you using Ajax at all? Make your post request (using a regular form submission) to a URL that performs then update and then redirects to the page that displays the result. – Quentin Nov 26 '15 at 11:25
  • I think that would be the best approach too but I'm working off an existing codebase (someone elses) and wanted to keep it as close to the original as possible for bug fixing before I look at rewriting parts of it. This issue seems to crop up (switching async to false) quite regularly and I've tried implementing other workarounds on here – alan oreilly Nov 27 '15 at 12:27

0 Answers0