user1192881
user1192881

Reputation: 1

iPhone & Phonegap

I try to connect to a simple json webservice from an iphone application - made in phonegap(so directly from the iPhone simulator) but I can't manage to do it.

Webserver is simple, receive 2 params and return same params to application - just for testing(located to another server). Client:

//here we make the call to the webservice
var TheURL = "http://www.wsurl.com/json_ws/json_webserver.php?";
TheURL += 'latitude=' + latitude + '&';
TheURL += 'longitude=' + longitude + '&';
TheURL += 'jsoncallback=?';

if(checkConnection()){
    $.getJSON(TheURL,function(msg){alert(msg); });   
}

Do you have any ideea about what should be wrong?

Thank you!

Upvotes: 0

Views: 357

Answers (2)

Devgeeks
Devgeeks

Reputation: 5647

I would check and make sure your web server's url (and any other externally loaded assets, etc) have been added to the PhoneGap WhiteList by adding it to the ExternalHosts key in the PhoneGap.plist file.

See the FAQ about external hosts here: http://wiki.phonegap.com/w/page/41631150/PhoneGap%20for%20iOS%20FAQ

Upvotes: 1

JoeCortopassi
JoeCortopassi

Reputation: 5093

Two things I would check is: 1) You are using jQuery, are you sure it has been included in the project?. 2) Put a NSLog after TheURL += 'jsoncallback=?';. Then copy and paste the concatenated url in safari to see if it works. My guess is the question mark in "jsoncallback=?' is what's causing the problem seeing as how you have no value there (question mark needs to be encoded if sent in a url. My guess is you are just missing the value that is supposed to take that question marks spot)

Upvotes: 0

Related Questions