Copy Code code 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 was:" + 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 was:" + 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 screenshot
$.post:
$.ajax:
Feeling $.post is used to submit forms, and to access the WCF AJAX service, you must also use $.ajax to specify Content-type.
Information found later: Http://stackoverflow.com/questions/2845459/jquery-how-to-make-post-use-contenttype-application-json
The above is written according to personal understanding, please correct me if there are any mistakes.