- The url shud be something similar to http://ipAddress or domainName/ajaxDemo/json/sample.json?callback=jsonCallback
- the ipAddress should the be ip of the system, if its localhost or 127.0.0.1 or 192.x.x.x the call would fail.
- The response json shud be wrapped with a callback method name I.e jsonCallback in our case
jsonCallback({ "sampleFlag1" : "This is sample value 1", "sampleData2" : "This is sample val 2", "sessionKey": "This is a key" }); - Datatype shud be “jsonp”
$.ajax({ type: 'GET', url: 'http://ipAddress or domain name/ajaxDemo/json/sample.json?callback=jsonCallback', data: {}, dataType:'jsonp', contentType: 'application/json', cache:false, jsonpCallback: 'jsonCallback', crossDomain : true, success: function(originalResponse, status, request){ $("#respCntr").html(originalResponse.sessionKey); }, error: function(XMLHttpRequest, textStatus, errorThrown) { $("#respCntr").html("error"); } }); - Add an entry in res/config.xml <access origin=”http://ipAddress or Domain name” subdomains=”true”/>
How to make Ajax request in PhoneGap using JQuery
January 17, 2013

Comments on: "How to make Ajax request in PhoneGap using JQuery" (1)
Iˇ¦ll right away take hold of your rss as I can not to find your email subscription hyperlink or newsletter service. Do you have any? Kindly permit me realize in order that I may just subscribe. Thanks.