JSONP无法在iPad上触发 [英] JSONP not firing on IPad

查看:80
本文介绍了JSONP无法在iPad上触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽一切可能后,我得出结论,这是iPad Safari的问题.该功能适用​​于MacBook上的FF,IE,Chrome和Safari.以下是我的简化代码.我有2个单独的JSONP调用,第一个可以在包括iPad在内的所有浏览器中使用.这只是基于模糊事件调用一个函数

After trying everything possible I've come to the conclusion this is an issue with IPad Safari. This works in FF, IE, Chrome, and Safari on MacBook. Below is my dumbed-down code. I have 2 separate JSONP calls, This first one works in all browsers including IPad. This simply calls a function based on a blur event

$('#gender').blur(function() { reTarget(); });

function reTarget() {
$.getJSON("http://host.com/Jsonpgm?jsoncallback=?", function() { } );
}

下面是发生问题的地方.在与上面的代码相同的页面上,是下面的代码,该代码基于提交按钮的单击调用一个函数.

Below is where things break. On the same page as the above code is the following, which calls a function based on a submit button click.

$(':submit').bind('click', function(event) {
if (checkThis() == false) { return false; }; });

$('form').bind('submit', function(event) {
 if (checkThis() == false) { return false; }; });

function checkThis() {
 $.getJSON("http://host.com/Jsonpgm.aspx?jsoncallback=?", function() { } );
}

此代码不会触发.我已经在警报之前放了警报,然后它们触发了.我查看了网络日志,但此json调用没有任何条目.我对此有任何建议.在这一点上,我担心从提交事件中触发jsonp是一个问题.

This code will not fire. I've put alerts right before it and they fire. I look at the web logs and there is no entry for this json call. I would take any suggestions on this. At this point I fear it's a problem with firing jsonp from a submit event.

推荐答案

此问题已解决.经过大量的Google和论坛讨论之后,发现页面拆卸是在发起json调用之前发生的.我更改了代码以停止按钮单击的传播,触发getJson调用,然后在回调函数中触发按钮单击.那解决了问题.无法正常工作的是将其设置为同步呼叫.

This has been solved. After much google and forums it turns out the page tear-down was occurring before the json call was initiated. I changed the code to stop the button click propogation, fire the getJson call, then in the callback function trigger the button click. That solved the problem. The thing that did not work was setting to a synchronous call.

这篇关于JSONP无法在iPad上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆