Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var loader = Titanium.Network.createHTTPClient();
- loader.onload = function() {
- alert("Hello");
- }
- loader.onError = function(e)
- alert("Error: " + e.error);
- }
- // add url in here
- loader.open("GET",'[URL HERE]');
- // Send the request.
- loader.send();
- var xhrSitelogin = Titanium.Network.createHTTPClient();
- xhrSitelogin.open('POST', webservice_url);
- xhrSitelogin.send({
- method : "userlogin",
- username : username,
- password : password
- });
- xhrSitelogin.setTimeout(10000);
- xhrSitelogin.onerror = function() {
- showAlertBox('Service timed out. Please try again.');
- //Hide Indicator
- };
- xhrSitelogin.onload = function() {
- alert(this.responseText);
- //RESPONSE RECEIVED
- };
- var api_url = 'http://myawesomeapi.heroku.com/users/' +
- taskRequest.onload = function() {
- var tasks = [];
- // code populating the tasks array
- alert(tasks);
- callback( tasks ); // invoke the callback
- }
- taskRequest.open('GET', api_url, false);
- taskRequest.setRequestHeader('Content-Type', 'application/json');
- taskRequest.send();
- loader.open("POST/GET","URL");
- loader.onload(response){
- //get the response
- console.log(this.responseText);
- };
- loader.send();
- Use this pattern.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement