IOS XHR requests are now working again.

  • 1
  • Announcement
  • Updated 8 years ago
Hardeep Shoker
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes

Posted 9 years ago

  • 1
Photo of Thomas Reinberger

Thomas Reinberger

  • 13 Posts
  • 0 Reply Likes
does this also apply to phonegap build? I cannot get xhr json requests to work on iOS :(
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Yes this applies to phonegap build. If you are not using build you will need to add your hosts to the phonegap.plist.

Hardeep Shoker
Photo of Thomas Reinberger

Thomas Reinberger

  • 13 Posts
  • 0 Reply Likes
Hi Hardeep,

I am using phonegap build and I still can't get the xhr requests to work on iOS5 (didn't try anything other for now).

I've prepared a sample app that makes the problem reproducable.

I you open http://www.c5solutions.de/downloads/i... , you'll see a page with nothing but a button. If you click on it, sample json data should be fetched with $.ajax(...) from http://www.c5solutions.de/downloads/j... . For me, this works on iOS5 and also on desktop browser (to no surprise). However, if I create an app from the given index.html file and the following config file:
-----------------------------------------------

test

test app description

Thomas Reinberger

<!-- sample preference specification -->

-----------------------------------------------

... the app loads, but nothing happens when I click on the button (neither "success" nor "error" is being alert'd).

Would be great if you could help me out because I don't want to use jsonp (which works in some cases, but has no proper error handling etc.)!

Best regards
Thomas
Photo of Thomas Reinberger

Thomas Reinberger

  • 13 Posts
  • 0 Reply Likes
I just realized that the config.xml code wasn't properly inserted into the post, so I made it available here:

http://www.c5solutions.de/downloads/c...

The entire test.zip is available here:

http://www.c5solutions.de/downloads/t...
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Can I get you application id please? the number in the url bar associated with the application. (http://build.phonegap.com/apps/#)

I would like to build against your application.

Hardeep Shoker
Photo of Thomas Reinberger

Thomas Reinberger

  • 13 Posts
  • 0 Reply Likes
Yes, of course!

The id is 44015.

Thomas
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Thanks,

I will take a look into it.

Hardeep Shoker
Photo of Mark Hollas

Mark Hollas

  • 9 Posts
  • 1 Reply Like
Hi,

Did anything come of this? I am getting the same problem. I have tried jQuery ajax and JSONP as well as a XMLHTTPRequest and XUI xhr request all to which I am getting returns when testing from desktop and mobile browsers but as soon as I put it them through phonegap build I can not even get my button to fire an event.

The only debug phonegap build debugger can give me is when I do a timeline record and it shows that the button click event fires a error..but there are no details given.

I have tried the demo app 'BeerMe' and loading it through phonegap build and it works. I can see my location as well as a location near me for beer. I used a similar request but it does not work (works on desktop and mobile browsers though)
function getIslandItem() {
x$().xhr('http://myservice.svc/getData', {
async: true,
method: 'get',
callback: function () {
alert("The response is " + this.responseText);
}
});
}

I have been chasing a solution for a few days now. Any help on getting a request out from phonegap would be much appreciated

Mark