简体   繁体   中英

Ajax call after form submit

I have the following problem with an ajax call after a form is submitted.

$('#EVE_fileupload').on('submit', function() 
{
    var apcID = $('#APC_UPLOAD_PROGRESS').val(); 

    GetUploadProgress(apcID);
    return true;
});

In this case the Ajax call in the GetUploadProgress function always returns an error. I guess this is due to the submit event in the browser. When i "return false" in the submit function, the ajax call is ok and i get the right response message.

Anyone a hint for me ?

You have to prevent page refresh after the form is submited. That's why your form is working when you are returning false.

$('#EVE_fileupload').on('submit', function(e) 
{

    e.preventDefault();

    var apcID = $('#APC_UPLOAD_PROGRESS').val(); 

    GetUploadProgress(apcID);

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM