87,990
社区成员
发帖
与我相关
我的任务
分享
var url = 'http://172.18.1.77/API/rs/country/list/';
$.ajax({
accepts: 'application/json',
url: url,
dataType: 'jsonp',
jsonp: 'callback',
contentType: 'application/json',
type: 'POST',
beforeSend: function (x) {
x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
},
success: function (json) { alert('succ') },
error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus) }
})
beforeSend: function (x) {
x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
},
都不可以设置contentType. 导致无法输出json格式的数据..
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
public Article AddArticle(Article article)
{
article.Title += "(模拟添加)";
article.Content += "(模拟添加)";
article.Id = 101;
return article;
}
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
public Article AddArticle(Article article)
{
article.Title += "(模拟添加)";
article.Content += "(模拟添加)";
article.Id = 101;
return article;
}
