最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2011年09月20日 22:19:14   作者:  
我注意到,當(dāng)在jquery中使用$.post()后,默認(rèn)的contentType是application/x-www-form-urlencoded 形式進(jìn)行了urlencoded - 當(dāng)我的asp.net MVC代碼需要的contentType=application/json
復(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

以上都是按個(gè)人理解所寫,有不對(duì)之處請(qǐng)指正

相關(guān)文章

最新評(píng)論

兰溪市| 平遥县| 普兰县| 家居| 密云县| 静海县| 临安市| 新龙县| 武汉市| 建瓯市| 哈巴河县| 哈巴河县| 海城市| 金秀| 德格县| 安阳县| 永定县| 徐闻县| 宁海县| 晋中市| 博白县| 闵行区| 和政县| 南江县| 柘荣县| 琼结县| 灯塔市| 五华县| 无极县| 商水县| 乐至县| 化州市| 大冶市| 建阳市| 康保县| 平顶山市| 阜新| 澄江县| 汝南县| 工布江达县| 缙云县|