Created
February 10, 2015 19:20
-
-
Save devmoreno/cbc9a16f2d84816316af to your computer and use it in GitHub Desktop.
ejemplo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//First http connection | |
(function(){ | |
var deferred = Q.defer(); | |
var url = "http://takeoutapi.azurewebsites.net/api/menu/", response; | |
var checkConn = Ti.Network.createHTTPClient({ | |
//On Sucess | |
onload : function() | |
{ | |
//Q | |
Ti.API.info("onload: "+this.responseText); | |
response = JSON.parse(this.responseText); | |
console.log('finished with one, give me another one'); | |
deferred.resolve(response); | |
}, | |
//On Error | |
onerror: function(){ | |
Ti.API.info("error"); | |
} | |
}); | |
//Open our connection and send them. Our results will be store on @response variable | |
checkConn.open("GET", url, true); | |
checkConn.setRequestHeader('Content-Type', 'application/json'); | |
checkConn.send(/* Params if POST or PUT */); | |
return deferred.promise; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment