没有带有数据的iframe中的JSONP回调

我正在使用铬。

我有一个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参数。 但这只是猜测。

我该怎么办 ?

我有一个表单,我正在编写自己的自定义函数,当单击表单的提交按钮时将调用该函数。 在那个function中,我没有阻止事件进一步传播。 这导致了这种奇怪的错误。

 $("form.ims.ajax").submit(function(event) { event.preventDefault(); // do your stuff }); 

这解决了这个问题。