I have a problem, when I use ajax post data into my express(nodejs) server, before server side response, the ajax .done still fire. So, I do a testing, to remove server side response, I found ajax still fire .done.
Server: Express(Node.js) Client: JQuery(3.2.1) post by ajax
ajax code:
$('#createNewGroup').click(function() {
$('#loading').show();
$.ajax({
url: 'list_live_createNewGroup',
type: 'POST',
cache: false,
data: { groupname: $('#groupname').val(),
groupdesc: $('#groupdesc').val(),
grouplocation: $('#grouplocation').val(),
accountname: $('#accountname').val(),
accountid: $('#accountid').val(),
bankname: $('#bankname').val() }})
.done(function(data) {
$('#loading').hide();
window.location.hash = '#mygroups';
window.location.reload(true);
})
.always(function(data) {
})
.fail(function(data) {
$('#loading').hide();
var response = JSON.parse(data["responseText"]);
alert(response["msg"]);
window.location.href = "list#creategroup";
});
});
server side code:
router.post('/list_live_createNewGroup', tools.checkUserLogin, function(request, response) {
var currentUser = new Parse.User();
currentUser.id = request.session.user;
// response.json(true);
});
via 章恩齊
No comments:
Post a Comment