I have a registration form and am using $.ajax
to submit it.(我有一个注册表,正在使用$.ajax
提交。)
$(document).ready(function() {
$("form#regist").submit(function() {
var str = $("#regist").serialize();
$.ajax({
type: 'POST',
url: 'submit1.php',
data: $("#regist").serialize(),
dataType: 'json',
success: function() {
$("#loading").append("<h2>you are here</h2>");
}
});
return false;
});
});
In my submit1.php file I check for the existence of fields email address and username in the database.(在我的Submit1.php文件中,我检查数据库中是否存在电子邮件地址和用户 名字段。) I wish to display an error message if those value exist without a page refresh .(如果这些值存在而没有页面刷新,则希望显示一条错误消息。)
How can I add this to the success callback of my AJAX request?(如何将其添加到我的AJAX请求的成功回调中?)
ask by noobcode translate from so