Ajax post being aborted by firefox (not seen in Chrome or IE)

前端 未结 8 496
再見小時候
再見小時候 2020-12-06 04:37

When using firefox, an ajax post request i have is being reported as aborted in firebug. The ajax post works fine in IE and Chrome. It is not a cross domain request. I tr

相关标签:
8条回答
  • 2020-12-06 05:15

    I would start by explicitly setting (and changing) some of the basic ajax options:

     cache: false,
     timeout: 60000,
     async: false
    
    0 讨论(0)
  • 2020-12-06 05:18

    Check the maximum post size setting on your server.

    0 讨论(0)
  • 2020-12-06 05:20

    Try only

    async: false
    

    in ajax option, I had the same problem.

    0 讨论(0)
  • 2020-12-06 05:20

    If you send this AJAX request from an event handler (example : click of a submit button), be sure to prevent the browser's default behavior (submitting the form), until you'll have 2 HTTP requests fired, with the first being aborted.

    You can use e.preventDefault() to achieve this.

    I just had this trouble on IE8.

    0 讨论(0)
  • 2020-12-06 05:23

    This is either a cross domain issue or it is an issue with Firefox aborting your request because request is async. For cross domain you can check the origin of your request and what is allowed on webservice. You might have to read up on CORS.

    If it is not cross domain then it is certainly a problem with request being async. Just change it to sync.

    0 讨论(0)
  • 2020-12-06 05:28

    What type of content your server returning. JSON or HTML content. Are you using charset=utf-8 in server content. Make sure your server response must be in JSON contentType. Another guess remove datatype: "html" from your code. Try for your luck.

    If your server returns json means, try below

    $.ajax({
                type: 'POST',
                url: '/Save',
                data: JSON.stringify(dataset),
                datatype: "json",
                contentType: "application/json",
                success: function (data, textStatus, jqXHR) {
                    //alert("success");
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    //alert("error");
                }
            });
    

    datatype: "json", contentType: "application/json" makes sense

    0 讨论(0)
提交回复
热议问题