Hri*_*kan 3 javascript php ajax jquery
我在使用Ajax调用的成功函数显示值时遇到问题.我的代码如下.
$.ajax({
type: "POST",
url: "http://localhost/practical 8/checkuser.php",
data: form_data,
success: function(response)
{
if(response == 'success'){
$("#errorUsername").html("<label class='error'>"+response+"</label>");
}else if(response == 'fail'){
$("#errorUsername").html("<label class='error'>"+response+"</label>");
}
}
});
Run Code Online (Sandbox Code Playgroud)
我的checkuser.php基本上回声"成功"或"失败".
我if和else如果我的成功函数语句不工作.但是这样做
$.ajax({
type: "POST",
url: "http://localhost/practical 8/checkuser.php",
data: form_data,
success: function(response)
{
$("#errorUsername").html("<label class='error'>"+response+"</label>");
}
}
});
Run Code Online (Sandbox Code Playgroud)
工作得很好.我究竟做错了什么?