jquery $.post and $.ajax access WCF AJAX Service

Source: Internet
Author: User
The code is as follows Copy Code
$.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, Rnerror message is:" + $ (jqxhr.responsetext). text ();
Window.alert (msg);
}
});

$.post is used to submit forms, and access to WCF Ajax service must be $.ajax to specify Content-type

You can ' t send application/json directly--it has to be a parameter of a get/post request.

So something like

  code is as follows copy code

$.post (URL , {json: "... json ..."}, function ());

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.