国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JQuyer $.post 與 $.ajax 訪問WCF ajax service 時的問題需要注意的地方

2019-11-20 23:40:21
字體:
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:

$.post('<%=this.AppPath %>DataService/InventoryUIService.svc/Rename', ///location.protocol + "http://" + 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:

image


$.ajax:

image

感覺$.post是用來提交forms的,而要跟wcf ajax service訪問,還必須得用$.ajax來指定Content-Type.

后來找到的資料: http://stackoverflow.com/questions/2845459/jquery-how-to-make-post-use-contenttype-application-json

以上都是按個人理解所寫,有不對之處請指正
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 黔西县| 来宾市| 崇文区| 辽宁省| 临城县| 五河县| 获嘉县| 东辽县| 江油市| 中超| 南乐县| 长沙县| 新田县| 襄城县| 剑河县| 眉山市| 商河县| 太仆寺旗| 东辽县| 临湘市| 北京市| 柳林县| 腾冲县| 黄大仙区| 浠水县| 忻州市| 怀宁县| 上犹县| 伊川县| 上饶县| 休宁县| 武乡县| 宁夏| 河池市| 固始县| 阿尔山市| 信丰县| 池州市| 汤原县| 金阳县| 札达县|