Generic handler, Get mode commit (data: Key value pair to be transferred)
Jquery.ajax (
{type: ' GET ',
URL: ' Gradehandler.ashx?startcount&stardescri ',
Data: {startcount:startcount, STARDESCRI:STARDESCRI},//(pair)
Data: ' {startcount: ' + Startcount + ', Stardescri: ' + Stardescri + ' '} ', (wrong)
ContentType: "Application/json; Charset=utf-8 ",
DataType: ' JSON ',
Success:function (Result) {
if (result)//returns True
Alert (' scored successfully! ‘);
Else
Alert (' scoring failed ' + result);
},
Error:function () {
Alert ("Ajax call Error");
}
}
);
General Handler, post submission (data: Key-value pair to be transferred)
Jquery.ajax (
{type: ' POST ',
URL: ' Gradehandler.ashx ',
Data: {startcount:startcount, STARDESCRI:STARDESCRI},//(pair)
Data: ' {startcount: ' + Startcount + ', Stardescri: ' + Stardescri + ' '} ',//(wrong)
ContentType: "Application/json; Charset=utf-8 ",//Cannot add this parameter
DataType: ' JSON ',
Success:function (Result) {
if (result)//returns True
Alert (' scored successfully! ‘);
Else
Alert (' scoring failed ' + result);
},
Error:function () {
Alert ("Ajax call Error");
}
}
);
/*
jquery calls the WebService method (only send a post-mode request);
When returning data in JSON format, you need to set ContentType to Application/json (data to be passed in JSON string format)
The returned data is a JSON object with the letter D as the key value.
*/
Jquery.ajax (
{type: ' POST ',
URL: ' Webservice/gradewebservice.asmx/usergrade ',
Data: ' {count: ' + Startcount + ', Descri: ' + Stardescri + ' '} ',//(yes)
Data: {count:startcount, DESCRI:STARDESCRI},//(wrong)
ContentType: "Application/json; Charset=utf-8 ",
DataType: ' JSON ',
Success:function (Result) {
if (RESULT.D)//returns True
Alert (' scored successfully! ' + RESULT.D);
Else
Alert (' scoring failed ' + RESULT.D);
},
Error:function () {
Alert ("Ajax call Error");
}
}
);
. NET jquery Ajax Applications (frontend)