Skip to content

Instantly share code, notes, and snippets.

@jew3lz
Created July 4, 2015 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jew3lz/ac274971af1f6f5da0d5 to your computer and use it in GitHub Desktop.
Save jew3lz/ac274971af1f6f5da0d5 to your computer and use it in GitHub Desktop.
$.ajax({
url: "login/" + code,
type: "get",
dataType:"text",
beforeSend: function (xhr) {
//将账号和密码放入HTTP请求的Header部分
xhr.setRequestHeader("name", name);
xhr.setRequestHeader("passwd", passwd);
},
//data是服务器返回内容
success: function (msg) {
//根据返回的map中的login值判断是否登陆成功
alert(222);
var ok = msg.login;
if (ok)
window.location = "/NETCTOSS/login/toIndex";
else {
//登陆未成功将返回的错误信息显示
$('#code_error').html(msg.code_error);
$('#error').html(msg.error);
//刷新验证码信息
$('#scode').attr("src", "/NETCTOSS/login/getCode");
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// 通常 textStatus 和 errorThrown 之中
// 只有一个会包含信息
alert(XMLHttpRequest.responseText);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment