【发布时间】:2013-12-23 16:47:25
【问题描述】:
我正在使用 chrome。
我有一个 iframe,我需要在其中点击一个支持 jsonp 的 url。
所以我使用了这个代码:
$.ajax({
dataType: 'jsonp',
url: my_url.endpoint + '/login/v1/token' ,
data: form_to_object("#signin_form"),
context: window,
// All Ajax calls to ABC are json
// Response statuses other than 200 are caught in a timeout
timeout: 10000, //10s
// Handler for successful calls to ABC: calls that return with statusCode 200
success: function(data, textStatus, jqXHR) {
// console.log(data);
alert("in access_token success");
if (data.hasOwnProperty('error_flag')) {
// Errors associated with this action are caught here:
// invalid_credentials, account_lockout, etc.
if (data.hasOwnProperty("jump")) {
ABC_show_frame(data.jump);
} else {
ABC_error_handler(data);
}
return;
}
// Auth succeeded, we can log in the user
GetUserProfile(data);
// ABC_success_handler(data);
},
error: function(data, textStatus, jqXHR) {
alert("In access_token error");
if (data.hasOwnProperty("jump")) {
ABC_show_frame(data.jump);
} else {
ABC_error_handler(data);
}
}
});
现在这段代码没有在附加data的参数后生成的url中附加callback=some_random_function_name。
喜欢https://abc/login/v1/token?username=ashish?password=abc,但不喜欢callback。
当我逐行调试它时,它确实使用callback=something 调用url,它似乎工作。 (似乎是因为有时它甚至在逐行调试时也没有附加。)
但是当我只是运行它时,它没有。
我认为问题可能是 jquery 中的一个错误,它还必须附加从form_to_object() 获得的data,并且可能会覆盖callback 参数。但这只是猜测。
我该怎么办?
【问题讨论】:
-
这可能是因为
context : window
标签: javascript jquery google-chrome iframe jsonp