Copy codeThe Code is as follows:
$. Post ('<% = this. appPath %> DataService/InventoryUIService. svc/rename', // location. protocol + "//" + location. host + location. pathname + "/Rename ",
Odata,
Function (result ){
$ DialogProcessing. dialog ("close ");
If (result. Success ){
Alert ("Success ");
}
Else {
Var msg = "Your submit fauiler, Detail message is:" + result. ErrorMessage;
Window. alert (msg );
}
},
"Json ");
$. Ajax ({
Url: '<% = this. AppPath %> DataService/InventoryUIService. svc/rename ',
Type: 'post ',
ContentType: 'application/json ',
DataType: 'json ',
Data: odata,
Success: function (result ){
If (result. Success ){
Alert ("Success ");
}
Else {
Var msg = "Your submit fauiler, Detail message is:" + result. ErrorMessage;
Window. alert (msg );
}
},
Error: function (jqXHR, textStatus, errorThrown ){
Var msg = "Your submit throw a error, \ r \ nError message is:" + $ (jqXHR. responseText). text ();
Window. alert (msg );
}
});
TCP Trace
$. Post:
$. Ajax:
It seems that $. post is used to submit forms. To access the wcf ajax service, you must use $. ajax to specify Content-Type.
Later found information: http://stackoverflow.com/questions/2845459/jquery-how-to-make-post-use-contenttype-application-json
All of the above are written according to my personal understanding. please correct me if any of the above is incorrect.