Я занимаюсь разработкой приложения SilverLight, в котором при закрытии браузера мне нужно выполнить вызов веб-службы.У меня есть метод веб-службы, который принимает один параметр.Когда пользователь нажимает на событие закрытия браузера.Я буду вызывать функцию doRelease ().Для метода releaseuser требуется параметр usertoken.
При вызове функции jQuery CallService () я получил ошибку
Строка: 186 Ошибка: ожидается объект
var varType;
var varUrl;
var varData;
var varContentType;
var varDataType;
var varProcessData;
//Generic function to call AXMX/WCF Service
function CallService() {
$.ajax({
type: varType, //GET or POST or PUT or DELETE verb
url: varUrl, // Location of the service
data: varData, //Data sent to server
contentType: varContentType, // content type sent to server
dataType: varDataType, //Expected data format from server
processdata: varProcessData, //True or False
success: function (msg) {//On Successfull service call
alert("success");
ServiceSucceeded(msg);
},
error: ServiceFailed// When Service call fails
});
}
function Temp(usertoken) {
varType = "POST";
varUrl = "http://localhost/TempWS/MachineHistoryWS.asmx?op=ReleaseUser";
varData = usertoken;
varContentType = "application/json; charset=utf-8";
varDataType = "json";
varProcessData = true;
alert("call service");
CallService();
}
function ServiceSucceeded(result) {//When service call is sucessful
alert("success");
varType = null; varUrl = null; varData = null; varContentType = null; varDataType = null; varProcessData = null;
}
function ServiceFailed(result) {
alert('Service call failed: ' + result.status + '' + result.statusText);
varType = null; varUrl = null; varData = null; varContentType = null; varDataType = null; varProcessData = null;
}
function doRelease() {
var usertoken = readCookie("usertoken");
Temp("usertoken");
}