[英]Ajax on Success message
I don't have much experience with ajax I want to use .post and in and if condition let the user know it succeed or not. 我对使用.post和in的ajax没有太多经验,如果条件让用户知道它成功与否,请使用in。
This is my .post code: 这是我的.post代码:
$.post("ajaxRegistering.php",{
name: name,
lastname: lastname,
secondlastname: secondlastname,
usernameone: usernameone,
email: email,
passwordone: passwordone,
studentnumberone: studentnumberone,
temp: temp
},
function(data,status){
// alert("Data: " + name + "\nStatus: " + status) ;
sweetAlert("Successfully", " created your account.", "success") ;
}) ;
Normal ajax that actually runs well but I'm still unable to add on failure case: 正常的ajax实际上运行良好,但是我仍然无法添加失败案例:
$.ajax ({
type: "POST",
url: "website.php",
data: data,
success: function(dataone){
sweetAlert("Successfully", " rolled in momentoSagrado.", "success") ;
}
}) ;
Can someone help me out I think is something simple that I'm doing wrong. 有人可以帮我吗,我认为这是我做错的简单事情。
per jQuery Docs .post()
is short hand for: 每个jQuery Docs .post()
的简称:
$.ajax({
type: "POST",
url: url,
data: data,
success: success,
dataType: dataType
});
so implement a success function like this: 因此实现一个成功函数,如下所示:
$.post( "website.php", function( data ) {
sweetAlert("Successfully", " created your account.", "success") ;
});
As far as getting the error on .post()
.. you'll need to chain the fail function (from docs) ... 至于.post()
上的错误,您需要链接fail函数(来自docs)...
// Assign handlers immediately after making the request,
// and remember the jqxhr object for this request
var jqxhr = $.post( "example.php", function() {
alert( "success" );
})
.done(function() {
alert( "second success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "finished" );
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.