[英]When I call generic handler using cross domain by ajax then data is undefined on success of ajax
When I call generic handler using cross domain by ajax then data is undefined on success of ajax. 当我通过ajax使用跨域调用泛型处理程序时,ajax成功时数据未定义。
function loadUser() {
currentUser = null;
$.ajax({
type: 'GET',
url: 'http://ips.rhinodev1.edge360.dev/EventVelocity/AsyncHandlers/GetCurrentUser.ashx?',
dataType: 'script',
crossDomain: true,
encode: true
}).done(loadUser_Done).fail(loadUser_Fail);
}
function loadUser_Done(data, txtStatus, jqXHR) {
if (txtStatus == "success") {
try { TestWildCard(); } catch (e) { currentUser_UseWildCardDNS = false; }
loadDevices();
}
else {
// Redirect To Login
window.location.href = "Login.aspx";
}
}
When calling loadUser()
function its call generic handler, and go to loadUser_Done()
function, in that I have got 'txtStatus' - "success" , but 'data' is undefined. 当调用
loadUser()
函数时,它调用泛型处理程序,并转到loadUser_Done()
函数,因为我有'txtStatus' - “成功”,但'data'是未定义的。
So, basically I didn't get my response, so how to solve this issue? 所以,基本上我没有得到我的回复,那么如何解决这个问题呢? Please give answer.
请给出答案。
basically you can just declare success
property in the ajax syntax: 基本上你可以在ajax语法中声明
success
属性:
function loadUser() {
currentUser = null;
$.ajax({
type: 'GET',
url: 'http://ips.rhinodev1.edge360.dev/EventVelocity/AsyncHandlers/GetCurrentUser.ashx?',
dataType: 'script',
crossDomain: true,
encode: true,
success: loadUser_Done(data, txtStatus, jqXHR)
error: function(error){
console.log(error);
}
})
}
function loadUser_Done(data, txtStatus, jqXHR) {
if (txtStatus == "success") {
try { TestWildCard(); } catch (e) { currentUser_UseWildCardDNS = false; }
loadDevices();
}
else {
// Redirect To Login
window.location.href = "Login.aspx";
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.