问题
I encountered a very peculiar problem and none of the answers I found here solves it.
On SOME clients (IE7, IE8) when I post the data using jQuery Ajax, such as:
$.ajax({
type: 'POST',
url: '<%= ResolveUrl"~/User.svc/GetUserListForCity") %>',
data: '{"city":' + cityId + '}',
contentType: 'application/json; charset=UTF-8',
dataType: 'json',
success: processList,
error: showErrorAlert
});
The error I am getting:
"The OperationFormatter could not deserialize any information from the Message because the Message is empty (IsEmpty = true)."
However when I attempt to use Fiddler to look at the data, the request is successful.
The server is IIS and the request is served by WCF Web Service (webHttpBinding). Removing contentType to allow defaults is being rejected by the server as it expects JSON. Any suggestions are very appreciated.
回答1:
Try this.. look's like you are sending data object is wrong
data: {"city": cityId }, // If cityID is a string this should do
OR
data: '{"city":"' + cityId + '"}',
There might also be a problem with the way you are sending the url.. Try using a absolute path and check if that works..
来源:https://stackoverflow.com/questions/12607500/jquery-ajax-post-data-is-empty-on-the-server-for-some-clients