Vin*_*upu 2 javascript titanium
我是Appcelerator钛工作室的新手.你能帮我解决一下如何在Appcelerator钛中调用webservice(基于Java).
您可以使用Titanium.Network.HTTPClient进行RESTful调用.
GET请求的示例
var url = "http://www.appcelerator.com";
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Ti.API.info("Received text: " + this.responseText);
alert('success');
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
timeout : 5000 // in milliseconds
});
// Prepare the connection.
client.open("GET", url);
// Send the request.
client.send();
Run Code Online (Sandbox Code Playgroud)
POST请求的示例
var xhr = Ti.Network.createHTTPClient();
xhr.onload = function(e) {
//handle response, which at minimum will be an HTTP status code
};
xhr.open('POST','http://www.myblog.com/post.php');
xhr.send({
title:'My awesome blog',
body:'Today I met Susy at the laundromat. Best day EVAR\!'
});
Run Code Online (Sandbox Code Playgroud)
它支持动词GET,POST,DELETE,PUT,PATCH
| 归档时间: |
|
| 查看次数: |
525 次 |
| 最近记录: |