P
P
pcdesign2016-04-07 12:30:34
JavaScript
pcdesign, 2016-04-07 12:30:34

How to make ajax async true work in FireFox?

After clicking on the submit button, ajax POST is sent first, and then the #OnClickOrder form itself is executed.
Here is the code:

jQuery("#OnClickOrder").submit(function(e) {
    jQuery.ajax({
           type: "POST",
           // async: false,
           cache: false,
           dataType: 'text',
           timeout: 1500,
           url: url,
           success: function(data)
           {
      
           }
         });
        });


In opera and in chrome the code works fine.
And in Firefox it starts working only when you add the line: Everywhere they write that using async: false is a bad practice. But, I can not find a clear solution, how to make ff work without this line.
async: false

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2016-04-07
@Taraflex

jQuery("#OnClickOrder").submit(function(e) {
    jQuery.ajax({
           type: "POST",
           // async: false,
           cache: false,
           dataType: 'text',
           timeout: 1500,
           url: url,
           success: function(data)
           {
      
           }
    });
    return false; //!!!!
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question