On Thursday, July 19, 2012 at 12:54 AM, bmoztalay wrote:
We've been having really weird issues. The gist of it is that we're writing a Phonegap app for Android and iPhone, and we have to use a web service by making POST requests to it with XML, and we get XML back. We can't use JSON or anything like that. So, the requests work in the iPhone emulator (not tested on device), Android emulator (running 2.3.1 and 4.0.3), and Chrome, just to be sure. Only one of them works on the actual Android device, the others don't.The one that works is the login request, which we make with a standard XmlHttpRequest, like so:function sendLoginRequestAndWaitForResponse() {request=new XMLHttpRequest();request.onreadystatechange = function() {if (request.readyState == 4) {if (request.status == 200 || request.status == 0) {//Parse the request.responseXMLalert(request.responseText);}}}postdata = "big XML string that we know works";try {request.open("POST","http://www.domain.com/location/of/login.cgi",true);request.send(postdata);} catch(e) {console.log(e);}}And the other request is made in the exact same way, just with a different URL to get to a different .cgi script, and a different XML string. When the request is made, it comes back and hits the alert(request.responseText), so we know that everything thinks it worked, but the alert is just blank.We also tried making the other request using jQuery.ajax, and it works just that same: on everything but the Android device. Here's that code:function sendOtherRequestAndWaitForResponse() {postdata="XML string, quintuple checked";$.ajax({data: postdata,type: 'POST',contentType: "text/xml",dataType: "xml",success:function(data, textStatus, response) {alert(response.responseText);},error:function(response, textStatus, errorThrown) {console.log("Error: " + response.responseText);console.log("Error: " + response.status);console.log("Error: " + response.statusText);console.log("Error: " + response.getAllResponseHeaders());alert("Error, could not locate vehicle, please try again later.");}});}This is a bit different, because it comes back into the error callback. However, all of the fields being logged are either blank or null. response.status is 0, though.We really have no idea what's going on. I can't understand why it works on all the other platforms, but not the actual device.And, just for the record, we have done the following:--
- Put the INTERNET permission in our manifest
- Whitelisted the entire internet in cordova.xml with <access origin="*"/>
- Made sure we had an internet connection on the phone
- Used the most recent version of Phonegap, 1.9
Thanks in advance for the help, let me know if you need any more information.
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
For more info on PhoneGap or to download the code go to www.phonegap.com
To compile in the cloud, check out build.phonegap.com