【www.bbyears.com--WCF】
代码如下 $.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, rnError message is:" + $(jqXHR.responseText).text();
window.alert(msg);
}
});
$.post是用来提交forms的,而要跟wcf ajax service访问,还必须得用$.ajax来指定Content-Type
You can"t send application/json directly -- it has to be a parameter of a GET/POST request.
So something like
代码如下$.post(url, {json: "...json..."}, function());