Advertisement
Guest User

Untitled

a guest
Jan 26th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. var loader = Titanium.Network.createHTTPClient();
  2. loader.onload = function() {
  3. alert("Hello");
  4. }
  5. loader.onError = function(e)
  6. alert("Error: " + e.error);
  7. }
  8.  
  9. // add url in here
  10. loader.open("GET",'[URL HERE]');
  11. // Send the request.
  12. loader.send();
  13.  
  14. var xhrSitelogin = Titanium.Network.createHTTPClient();
  15. xhrSitelogin.open('POST', webservice_url);
  16. xhrSitelogin.send({
  17. method : "userlogin",
  18. username : username,
  19. password : password
  20. });
  21. xhrSitelogin.setTimeout(10000);
  22.  
  23. xhrSitelogin.onerror = function() {
  24. showAlertBox('Service timed out. Please try again.');
  25. //Hide Indicator
  26. };
  27. xhrSitelogin.onload = function() {
  28.  
  29. alert(this.responseText);
  30. //RESPONSE RECEIVED
  31. };
  32.  
  33. var api_url = 'http://myawesomeapi.heroku.com/users/' +
  34.  
  35. taskRequest.onload = function() {
  36.  
  37. var tasks = [];
  38.  
  39. // code populating the tasks array
  40.  
  41. alert(tasks);
  42.  
  43. callback( tasks ); // invoke the callback
  44. }
  45.  
  46. taskRequest.open('GET', api_url, false);
  47.  
  48. taskRequest.setRequestHeader('Content-Type', 'application/json');
  49.  
  50. taskRequest.send();
  51.  
  52. loader.open("POST/GET","URL");
  53. loader.onload(response){
  54. //get the response
  55. console.log(this.responseText);
  56.  
  57. };
  58. loader.send();
  59. Use this pattern.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement