javascript - Calling RESTful webservices in Appcelerator Titanium Studio -
i'm new appcelerator titanium studio. please me out how call webservice (java based) in appcelerator titanium.
you can use titanium.network.httpclient make restful calls.
example requests
var url = "http://www.appcelerator.com"; var client = ti.network.createhttpclient({ // function called when response data available onload : function(e) { ti.api.info("received text: " + this.responsetext); alert('success'); }, // function called when error occurs, including timeout onerror : function(e) { ti.api.debug(e.error); alert('error'); }, timeout : 5000 // in milliseconds }); // prepare connection. client.open("get", url); // send request. client.send();
example post requests
var xhr = ti.network.createhttpclient(); xhr.onload = function(e) { //handle response, @ minimum http status code }; xhr.open('post','http://www.myblog.com/post.php'); xhr.send({ title:'my awesome blog', body:'today met susy @ laundromat. best day evar\!' });
it supports verbs get, post, delete, put, patch
Comments
Post a Comment