简体   繁体   English

Phonegap 3.6.3 Ajax无法正常工作

[英]Phonegap 3.6.3 ajax not working

I'm confused here. 我在这里很困惑。 If I call the following from chrome console: 如果我从chrome控制台调用以下命令:

$.get('http://ipinfo.io/json').success(function(d){ console.log(d) }).error(function(d){ console.log(d) })

it displays the object as expected and then logs the result of my request (whether is succeeds, fails, etc...). 它按预期显示对象,然后记录我的请求结果(是否成功,失败等等)。

If i run the exact same code in the web inspector of safari connected to my app in (via the web inspector in iOS) I still is the object created, but the result is never displayed. 如果我通过(通过iOS中的Web检查器)在连接到我的应用的safari的Web检查器中运行完全相同的代码,则我仍然是创建的对象,但结果永远不会显示。

However if I expand the object, I can see that it has returned with a result, but never called the "success" callback. 但是,如果我展开对象,则可以看到它返回了结果,但从未调用过“成功”回调。 Any idea why it is ignoring the callback? 知道为什么它忽略了回调吗?

EDIT: The really weird thing is if the save the above call in a variable: 编辑:真正奇怪的是,如果将上面的调用保存在变量中:

var c  = $.get('http://ipinfo.io/json').success(function(d){ console.log(d) }).error(function(d){ console.log(d) })

and then read c.responseText .. the result is right there... my "success" callback is just never fired..? 然后读取c.responseText ..结果就在那里...我的“成功”回调从未被触发。

try using this code to show your result instead [Object object] 尝试使用此代码显示结果而不是[Object object]

$.get('http://ipinfo.io/json').complete(function(d) {
    JSON.stringify(d);
});

Ok, so I never figured out why this was happening, but rebooting the computer and/or using another computer solved the problem. 好的,所以我从来没有弄清楚为什么会这样,但是重新启动计算机和/或使用另一台计算机解决了问题。 So I think the safari developer features where having some serious problems. 因此,我认为Safari开发人员功能存在一些严重问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM