I am writing a html page which uses ajax with xhr to upload a form data(including text and files)to the nodejs server.
But after nodejs server receives the data and send back a string "1" to the frontend.The js code cannot run its success callback function.
function show_status(status) {
alert(status);
if (status == '1') {
$('#status').text('Add game succeed!!');
} else {
$('#status').text('Add game failed!!');
}
}
$(document).ready(function() {
$('#addformonline').submit(function(e) {
$('#status').text('');
$.ajax({
type: 'POST',
dataType: 'text',
xhr:function() {
myXhr = $.ajaxSettings.xhr();
return myXhr;
},
data: new FormData($('#addformonline')),
success: show_status,
error: function(){alert('error');}
});
return false;
});
});