0
votes

I have developed an application where i can get data from server url http://user:[email protected]:xxxx/odata/OdataTMEDVDB/dbname?$format=JSON&$filter=YEAR%20eq%202015&$top=10&$callback=?

This query working fine on browsers, after compile using phonegap, the event does not fire at all to get data here is the code

var query = "http://user:[email protected]:xxxx/odata/OdataTMEDVDB/dbname?$format=JSON&$filter=YEAR%20eq%202015&$top=10&$callback=?"; //this is my callback

                 $.ajax({
                    dataType: 'jsonp',
                    url: query,
                    jsonpCallback: 'callback',
                    success: callback
                });

                function callback(result) {
                    alert("hello");
                    alert(result.d.results.length);
                    var shows = result.d;
                    $('#resultdata').html(shows);
                }

Please advice

1

1 Answers

1
votes

Some browser can refuse the URL basic auth password. Try to add your password directly into the header by using beforeSend:

$.ajax({
   dataType: 'jsonp',
   url: 'http://xx.xx.x.xxx:xxxx/odata/OdataTMEDVDB/dbname?$format=JSON&$filter=YEAR%20eq%202015&$top=10&$callback=?',
   jsonpCallback: 'callback',
   success: callback,
   //New code:
   beforeSend: function (xhr) {
      xhr.setRequestHeader ("Authorization", "Basic user:password");
   },
});