html+jquery项目发布
项目是使用Html+jquery提交数据到httphandle里面访问数据库,问题是:代码在vs中运行没有问题,但是发布到IIS中
$.ajax({
type: "POST",
cache: false,
data: "username=" + username + "&password=" + password + "",
url: "Handle/LoginHandler.ashx",
success: function(data) {
if (data == "帐号登录成功") {
window.location.href = "Index.html";
} else {
alert(data);
}
}, error: function(data) {
alert("登录失败");
}
});
一直执行error块,而不执行success块,不知是什么原因,求解决方法。
[解决办法]
- C# code
$.ajax({ type:"post",//请求方式 url:"../ajax/AjaxLogin.ashx",//载入页面的URL地址 data:{username:$("#TxtUserName").val(),userpwd:$("#TxtUserPwd").val()}, success:function(data){//返回成功的函数 if(data =="0"){ show(); setTimeout("window.location.href='../FrameSet/FatherFrame.aspx';",700); }else { alert('账号密码错误或您的账号未被启用!'); document.getElementById("TxtUserName").value=""; document.getElementById("TxtUserPwd").value=""; document.getElementById("TxtUserName").focus(); } } });