我有一个基本的登录表单设置,我正在使用ajax请求将两个变量(登录密码)发送到另一个页面,该页面检查并相应地返回状态.我的ajax代码
$('form.login_form').on('submit', function(){
var that = $(this),
url = "textlogin.php",
type = that.attr('method'),
data = {};
that.find('[name]').each(function(index, value){
var that = $(this),
name = that.attr('name'),
value = that.val();
data[name] = value;
});
$.ajax({
url: url,
type: type,
data: data,
success: function(response){
if(response==""){
$('#login_err').html("its null");
}else{
$('#login_err').html(response);
}
}
});
return false;
});
不起作用,成功函数总是返回null.代码工作正常,直到我没有使用ajax和jquery对话框登录.
我试过的事情:
1.设置内容类型
2.设置dataType
3.使用$.post,什么不是.