Reputation: 163
I have a jquery ajax calls I'm making cross domain using jsonp. The code is:
$.support.cors = true;
$.allowCrossDomainPages = true;
$.ajax({
dataType: 'jsonp',
type: "POST",
url: "http://my-url.com/getSearchResults.php",
data: {
userId: localUserId,
searchLocation: decodeURIComponent(searchLocation),
searchCategory: searchCategory
}
})
.done(function(items) {
alert(items);
});
When I run this in a normal browser I get in the alert box [object object] as I should, but when I run it on an android mobile browser it returns a blank alert box.
My PHP contains headers to allow cross domain.
The actual resonse from the ajax call (the object) is something like this:
[{
"address": "London Road, Brighton, United Kingdom",
"details": {
"id": "1",
"name": "kav 2",
"logo": "user_content\/1167327737_images.jpg",
"favorite": "0",
"feedback": 0
}
}];
I am trying to find a solution for the past 3 days. Can anyone help?
Upvotes: 1
Views: 2407
Reputation: 163
It took me a while but I found the solution.
Even though Ajax calls of datatype jsonp are always sent with $_GET no matter what you put in the type, With android browser, if you put in the type POST they will be sent as $_POST.
Once I changed the type to GET everything started working again.
Upvotes: 1