How can i make a asmx web method that can accept a content type "application/x-www-form-urlencoded".
Please see below code:
// 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;
}
The above code is an example of "application/x-www-form-urlencoded" content type request. I need to know how to make an asmx method to accept those request.
Furthermore, I need to upgrade also that old ajax and replace it using ajax in jquery. Please advise also how to do it.