最新国产好看的视频,伊人天堂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)論

呼伦贝尔市| 庆元县| 贡山| 丹棱县| 芜湖市| 外汇| 聊城市| 棋牌| 大丰市| 南充市| 米林县| 互助| 松原市| 嘉兴市| 烟台市| 广饶县| 永兴县| 怀化市| 广东省| 荣成市| 上饶县| 胶州市| 通河县| 新兴县| 鲁甸县| 南雄市| 天台县| 牙克石市| 泗洪县| 武强县| 苗栗市| 曲阳县| 巴青县| 临颍县| 舞钢市| 长治县| 名山县| 通州市| 扎囊县| 巴林左旗| 天柱县|