0

I have created a PHP web application and use MySQL as database backend, but there is an 'Aborted' note on Firebug's Net panel's status column when I access the web page. Why?

 $('#submit').on('click', function () {
//        e.preventDefault();
        var formData = JSON.stringify($("#frmPayoye").serializeObject());
        console.log(formData);
        $.ajax({
            type: "POST",
 
            url: "http://www.sanaroopay.com/pg/api/ectransact/", 
            data: formData,
            cache: false,
            timeout: 60000,
            async: false,
            processData: true,
            dataType: 'json',   //you may use jsonp for cross origin request
            contentType: "application/json; charset=utf-8",
            crossDomain: true,            
            success: function (data) {
                alert(JSON.parse(data));
//                alert("ok");
                console.log("success");
//                window.location.assign('https://secure.payoye.net/web/merchant');
            },
            error: function () {
                console.log("Failed");
            }
        });
    });
Sebastian Zartner
  • 18,808
  • 10
  • 90
  • 132
  • 1
    Possible duplicate of [How to solve Firebug’s “Aborted” messages upon Ajax requests?](http://stackoverflow.com/questions/12116641/how-to-solve-firebug-s-aborted-messages-upon-ajax-requests) – Severino Lorilla Jr. Apr 05 '16 at 06:27

2 Answers2

1

You are not cancelling the form submission so the Ajax call is aborted and the page submits the form as it is designed to do. So you need to stop the form submission.

$('#submit').on('click', function (evt) { 
    evt.preventDefault(); //stop the default action of the button
    //Rest of your code
});
epascarello
  • 204,599
  • 20
  • 195
  • 236
-1

Please see the documentation of XHR open() for example here: https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest

Note: Calling this method an already active request (one for which open()or openRequest()has already been called) is the equivalent of calling abort().

Just create a new XHR instance whenever you need one. Better yet, use jQuery or other JS library to do AJAX. It should shield you from these intricacies.

How to solve Firebug’s “Aborted” messages upon Ajax requests?

Community
  • 1
  • 1
Severino Lorilla Jr.
  • 1,637
  • 4
  • 20
  • 33