HTTPClient not sending data via GET right
I'm trying to get the response from http://example.com/some/path/?foo=bar.
I've tried this:
var url = "http://example.com/some/path/";
xhr.open("GET",url);
xhr.onload = function(userLocation) { Ti.APP.info('In onload'); }
xhr.send({foo:'bar'});
and
var url = "http://example.com/some/path/";
xhr.open("GET",url);
xhr.onload = function(userLocation) { Ti.APP.info('In onload'); }
var data = {};
data.foo = 'bar';
xhr.send(Ti.JSON.stringify(data));
And I even tried:
var url = "http://example.com/some/path/?foo="+'bar';
xhr.open("GET",url);
xhr.onload = function(userLocation) { Ti.APP.info('In onload'); }
xhr.send({foo:'bar'});
None of these approaches seems to work? This has to be something stupid I'm doing or this is another one of those QA things missed in 1.3. Any advice?
3 Answers
-
This works for me:
var url = 'http://' + saved_ip_address + '/control.php?network=' + network + '&action=' + action; var ConnectionAction = Ti.Network.createHTTPClient(); ConnectionAction.open("GET", url); ConnectionAction.send();
In this case, I don't care about the response, but you can just add:
ConnectionAction.onload = function() { alert(this.response); }
If you want to do something with it…
-
You have to put your request in "POST" because you send parameters
-
What was the answer to this? I have the same behaviour - I am specifying "GET" but it is always using "POST". This indeed is elementary - please point me in the right direction…