我已经编写了一个代码来在我的Titanium项目中使用WCF服务。
Alloy.Globals.wcfservice=function callservice()
{
//fetching data from server.
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(1200);
console.log(xhr.status);
console.log(xhr.statusText);
xhr.onerror = function(e) /* on error in getting data from server */
{
//check response status and act aaccordingly.
if (xhr.status != 200) {
alert("The service is currently unavailable. Please Try Again Later.");
return;
}
};
//on getting response from server.
xhr.onload = function()
{
alert(this.responseText);
var response = XML.parse(this.responseText);
};
//set the url for the service to the get student courses
var request_url = getWebserviceURL() + "GetAvailableAppointmentFromWCF";
console.log(request_url);
xhr.open("POST", request_url);
xhr.send();
};
但我总是收到状态为0,“该服务目前无法使用。请稍后再试”。我在这段代码中做错了什么?