如何传递UserName& Ajax中的密码 [英] How to Pass UserName & Password in Ajax
本文介绍了如何传递UserName& Ajax中的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
我使用自定义身份验证创建了OData服务,如何传递UserName& Ajax中的密码。请注意,如果代码没有安全性,工作正常。
请帮助这个
以下是我的代码
Dear,
I created OData Services with Custom Authentication, How to pass the UserName & Password in Ajax. Note that without having security below code working fine.
Please help on this
Below is my Code
var _url = "http://localhost:49497/DataService.svc/Mst_User?$filter=Us_Name eq 'Basit' and Us_Password eq 's'&$format=json";
$.ajax({
type: "GET",
url: _url,
timeout: 10000,
async: true,
dataType: "json",
contentType: "application/jsonp; charset=utf-8",
success: function (data)
debugger;
//
if (data.d.length > 0 && data.d[0].Us_Admin == 1) {
var Adminrole = data.d[0].Us_AdminModule
var UsNo = data.d[0].Us_No
} else {
Alter(‘Login Failed’)
}
},
error: function (xhr, status, error) { // flow always comes in error callback even url returns true and this is the issue.
Alter(‘Login Failed’)
}
});
}
};
谢谢
Basit
Thanks
Basit
推荐答案
filter = Us_Name eq'Basit'和Us_Password eq''s&
filter=Us_Name eq 'Basit' and Us_Password eq 's'&
format = json;
format=json";
.ajax({
type: GET,
url:_url,
超时: 10000 ,
async: true ,
dataType: json,
contentType: application / jsonp; charset = utf-8,
成功: function (数据)
调试器;
//
if (data.d.length> 0 && data.d [ 0 ]。Us_Admin == 1 ){
< span class =code-keyword> var Adminrole = data.d [ 0 ]。Us_AdminModule
var UsNo = data.d [ 0 ]。Us_No
} else {
Alter('登录失败')
}
},
错误: function (xhr,status,error){ // 流总是出现错误回调,即使url返回true,这是问题。
改变('登录失败')
}
});
}
};
.ajax({ type: "GET", url: _url, timeout: 10000, async: true, dataType: "json", contentType: "application/jsonp; charset=utf-8", success: function (data) debugger; // if (data.d.length > 0 && data.d[0].Us_Admin == 1) { var Adminrole = data.d[0].Us_AdminModule var UsNo = data.d[0].Us_No } else { Alter(‘Login Failed’) } }, error: function (xhr, status, error) { // flow always comes in error callback even url returns true and this is the issue. Alter(‘Login Failed’) } }); } };
谢谢
Basit
Thanks
Basit
这篇关于如何传递UserName& Ajax中的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文