Using datajs in Phonegap Application-ios?

Mar 20, 2013 at 6:14 AM
Greetings,

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..
Coordinator
Mar 21, 2013 at 10: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 OData.read ?
  • Is there any error that occur when using Phonegap ?

Regards,
Hussein
Mar 22, 2013 at 9:12 AM
Edited Mar 22, 2013 at 9: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;



                  OData.read("http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')/Orders",
                             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(str);
                             alert('after for');
                             }, function (err) {
                             alert(err.message);
                             });
              }

In the config.xml,I have set

<access origin="*" />

It does not throw any error but nothing happens.


Thanks
Priya23
Coordinator
Mar 22, 2013 at 6: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.

Regards,
Hussein