0

I have the following code that gets executed when button is pressed.

function signInButton(){
    var data = {
            "userName" : $("#text_userName").val(),
            "password" : $("#password_signInPassword").val()
        };

    var userName = $("#text_userName").val();
    var password = $("#password_signInPassword").val();

    var loadUrl= parentApp + "/executeLogin.htm";
    makeNetCall(loadUrl, data, function(responseJson) {
            jQuery("#text_userName").val('');
            jQuery("#password_signInPassword").val('');
            post('/TestWebProject/pages/SetSession.jsp', {name: 'Johnny Bravo'});           

    }, 
    function(err) { 
        jQuery("#text_userName").val('');
        jQuery("#password_signInPassword").val('');
        alert("Invalid Username/Password"); 
    });

}

but this post request post('/TestWebProject/pages/SetSession.jsp', {name: 'Johnny Bravo'}); is getting aborted.

post method is

function post(path, params, method) {
    method = method || "post"; // Set method to post by default if not specified.

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    for(var key in params) {
        if(params.hasOwnProperty(key)) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", key);
            hiddenField.setAttribute("value", params[key]);

            form.appendChild(hiddenField);
         }
    }

    document.body.appendChild(form);
    form.submit();
}

enter image description here

There is no other request that could abort my post request. Why is this happening then? Any has encountered this before? solution/workaround?

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289

1 Answers1

0

Read NS_BINDING_ABORTED Javascript window.location.replace()

Based on your network output, it looks like you are redirecting to the login while the post is still going on. I'm not sure what the code of makeNetCall looks like, but I assume something in there is causing the page to change before the form is even done loading.

Community
  • 1
  • 1
Stephen
  • 5,362
  • 1
  • 22
  • 33