$.ajax
$.ajax({ type: 'POST', url: 'server/login.ashx', dataType: "json", data: { username: $('input[name="username"]').val(), password: $('input[name="password"]').val() }, success: function (d) { if (!d.UserName) { alert("账号或密码错误。") return; } if ($('input[name="remember"]').prop("checked")) { for (var k in d) { $.cookie(k, d[k], { expires: 7 }); } } else { for (var k in d) { $.cookie(k, d[k]); } } window.location.href = 'index.html'; }, error: function (x, s, e) { alert(e + 'error'); } })