我有以下javascript / jquery语法,它从AWebpageThatProducesTextResult.aspx
异步获取数据。
该网页会生成text/plain
或SUCCESS
的{{1}}输出,并具有以下设置
FAIL
但是,我似乎无法比较 Response.Clear(); //clear all prior output
Response.ContentType = "text/plain;"; /*we just need a plain response so use text only*/
Response.Write("SUCCESS"); /*or FAIL, depending on supplied*/
Response.End();
与jQuery success: function (data
数据结果的结果,(请参阅注释行以获取更多信息
$.ajax
如何正确进行 $.ajax("Main/pAdministrator/AWebpageThatProducesTextResult.aspx?ver=111",
{
type: 'POST',
dataType: 'text', //we just need to know if it succeded or failed, so use text
data: {
action: 'logIn',
uname: $("#txtUsername").val(),
pword: $("#txtPassword").val(),
ipadr: hisIP
},
success: function (data, status, xhr) { //on success.
//has result.. bu does not redirect. damn. HOW DO I PROPERLY DO A CONDITION?
if (data === 'SUCCESS')
{
window.location.replace("Home.aspx");
}
else {
swal(data); //always goes here even if the login is
//correct! even if it says "SUCCESS"!
}
},
error: function (jqXhr, textStatus, errorMessage) {
}
});
比较?我认为这是问题的根源