如何创建一个可以接受内容类型“application / x-www-form-urlencoded”的asmx web方法。
请参阅以下代码:
// create request object
var req = createRequest();
var params = "core_lesson=English&core_grade=80&core_average=90";
// set up request parameters - uses POST method
req.open('POST','commit.asmx/commit',false);
// request headers
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-length", params.length);
req.setRequestHeader("Connection", "close");
// submit to the server for processing
req.send(params);
function createRequest() {
var request;
try {
request = new XMLHttpRequest();
}
catch (tryIE) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (tryOlderIE) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed) {
alert("Error creating XMLHttpRequest");
}
}
}
return request;
}
以上代码是“application / x-www-form-urlencoded”内容类型请求的示例。我需要知道如何使asmx方法接受这些请求。
此外,我还需要升级旧的ajax并在jquery中使用ajax替换它。请告知如何操作。