我遇到了一个非常特殊的问题,我在这里找到的答案都没有解决。
在我使用jQuery Ajax发布数据时,在某些客户端(IE7,IE8)上,例如:
$.ajax({
type: 'POST',
url: '<%= ResolveUrl"~/User.svc/GetUserListForCity") %>',
data: '{"city":' + cityId + '}',
contentType: 'application/json; charset=UTF-8',
dataType: 'json',
success: processList,
error: showErrorAlert
});
我得到的错误:
“OperationFormatter无法反序列化Message中的任何信息,因为Message为空(IsEmpty = true)。”
但是,当我尝试使用Fiddler查看数据时,请求成功。
服务器是IIS,请求由WCF Web服务(webHttpBinding)提供。删除contentType以允许默认值被服务器拒绝,因为它需要JSON。 任何建议都非常感谢。
答案 0 :(得分:0)
试试这个..看起来就像你发送数据对象错误
data: {"city": cityId }, // If cityID is a string this should do
OR
data: '{"city":"' + cityId + '"}',
您发送网址的方式可能也有问题。尝试使用绝对路径并检查是否有效..