Using datajs in Phonegap Application-ios?

Mar 20, 2013 at 7:14 AM

I am performing a simple OData.Read on a webservice using the datajs-1.0.0.js. Its works fine on browser.However when I run run it on a Phonegap iOS Application its does not work.

Thanks in Advance..
Mar 21, 2013 at 11:41 PM
Hi priya23.

I tried datajs-1.0.0.js with Phonegap and I used OData,Read with Netflix Srvice , it worked fine.
So in order to detect the problem, I have twoquestions:
  • Did you set enableJsonPCallback in ?
  • Is there any error that occur when using Phonegap ?

Mar 22, 2013 at 10:12 AM
Edited Mar 22, 2013 at 10:13 AM
Hello Hussein,

I am using datajs1.1.0.js and cordova iOS project version 2.4.

I have written the following code in device ready event of Page
                 OData.defaultHttpClient.enableJsonpCallback = true;

                             function(data, response){

                             alert('oData Function');

                             var str;
                             alert('before for');
                             for(var objRec in data.results){
                             var obj = data.results[objRec];

                             str = str + ' '+obj.OrderID;
                             alert('after for');
                             }, function (err) {

In the config.xml,I have set

<access origin="*" />

It does not throw any error but nothing happens.

Mar 22, 2013 at 7:14 PM
This should be working fine, maybe another two questions can help:
  • Do you run this code after deviceready event ?
  • Is these alerts are navigator.notification.alert or just alert?. because I think alerts don't work with phonegap.