xhr.open('POST', 'url-here.com'); does not work
POST doesn't work, but GET does. Any idea how to make it work?
3 Answers
-
A good way to start is posting your code here, may be you are missing the parameters.
-
var xhr = Titanium.Network.createHTTPClient(); xhr.onerror = xhrOnError; //xhr_onError function working xhr.onload = function() { Ti.API.info(this.responseText); Ti.API.info(this.status); if(this.status == 200) { Ti.API.info('Getting back: ' + this.responseText); } else { Ti.UI.createAlertDialog({ title:'Sorry', message:'Please try again.' }).show(); } }; Ti.API.info("sending: " + jsonData); xhr.open('POST', 'http://someurl.com/index.php'); // index.php is just print_r($_POST) or print_r($_REQUEST) xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Accept', 'application/json'); xhr.send(jsonData);
-
The example shown should work fine. Check that you got Internet connectivity..