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

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

 更新時間:2011年09月20日 22:19:14   作者:  
我注意到,當在jquery中使用$.post()后,默認的contentType是application/x-www-form-urlencoded 形式進行了urlencoded - 當我的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

以上都是按個人理解所寫,有不對之處請指正

相關(guān)文章

最新評論

元阳县| 泗水县| 延吉市| 岳西县| 将乐县| 淳化县| 夏河县| 湘乡市| 安吉县| 环江| 恩平市| 犍为县| 辽阳县| 腾冲县| 博湖县| 田阳县| 房产| 洪泽县| 韶关市| 饶阳县| 福海县| 芦溪县| 班戈县| 赣榆县| 庆城县| 改则县| 施甸县| 承德市| 垣曲县| 兖州市| 稻城县| 治多县| 青田县| 新巴尔虎右旗| 富顺县| 康平县| 镇江市| 比如县| 马边| 湾仔区| 墨江|