Phonegap Jquery mobile cross domain ajax request not working


I am trying to make a ajax request from my phonegap app to a serverside code written in php which is on my localhost. I am trying to use the jsonp request. This is my code

$.ajax({ url: 'http://localhost/score-tracker/get-groups.php', type: 'GET', contentType: "application/json", async: true, dataType: 'jsonp', crossDomain: true, success: function(resp){}, error: function(err) {} });

But the control does not return either in error or success callbacks. I even have this enabled :

$.support.cors = true; $.mobile.allowCrossDomainPages = true;

WHen i check the request in chrome console, I find the status as "failed" and type as "pending"

This is my server side code :

require_once('AddGroup.php'); header('content-type: application/json; charset=utf-8'); header('Access-Control-Allow-Origin: *'); $a = json_encode(array('a' => 1, 'b' => 2)); echo $_REQUEST['callback'].'('.$a.')';

Please help me. I am really stuck with this.

Thank you


I got the problem solved. Just posting the answer if any one finds it helpful

$.ajax({ url: 'http://<ip>/score-tracker/get-groups.php', type: 'GET', contentType: "application/json", async: true, dataType: 'jsonp', crossDomain: true, success: function(resp){}, error: function(err) {} });

And in the http.d conf file of apache I had permission denied to the www directoy for which I was getting the forbidden error. I allowed access to that directory and the problem was solved.


  • Silverlight-to-WCF cross-domain exception, but clientaccesspolicy.xml is being read successfully
  • Build a dynamic table using array data generated from PHP in JSX/React
  • What to do when an API doesn't allow Access-Control-Allow-Origin
  • The request sent by the client was syntactically incorrect
  • Zend_Form Jquery & fileUploadErrorIniSize
  • How do I send a form with a request promise?
  • formediting modals shows at wrong position
  • @Post method with capturing parenthesis in @Path not matched in Jersey
  • Getting zero results in search using elastic4s
  • Converting datatype Char to Nvarchar
  • What is corresponding c++ data type to SQL numeric(18,0) data type?
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • pyodbc doesn't report sql server error
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • MongoError: Incorrect arguments
  • Get data from AJAX - How to
  • Nant, Vault & Windows Integrated Authentication
  • Bug in WPF DataGrid
  • Obtain ObjectIdHex value from mgo query
  • jQuery tmpl and DataLink beta
  • How can I estimate amount of memory left with calling System.gc()?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How to stop GridView from loading again when I press back button?
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Django query for large number of relationships
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • Net Present Value in Excel for Grouped Recurring CF
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?