简体   繁体   中英

Phonegap 3.6.3 ajax not working

I'm confused here. If I call the following from chrome console:

$.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.

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..?

try using this code to show your result instead [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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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