I couldn't reproduce your issue. It could be that it has been fixed in the jQuery source.
This works for me using jQuery 1.7.1:
Code:
var obj = { 'foo': '??' };
$.ajax({
type: 'POST',
url: 'http://localhost/test10.php',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(obj),
success: function(msg) {
console.info(msg);
}
});
This sends the JSON string as the body of the POST request. While this is valid HTTP, it is atypical. Usually POST requests consist of a set of name/value pairs, which is denoted by the content type application/x-www-form-urlencoded.
You can send a request of this form using $.post:
Code:
$.post(
'http://localhost/test10.php',
{'json': JSON.stringify(obj)},
function(msg) {
console.info(msg);
}
);
Note that in this case, the JSON string is passed as a parameter named 'json'.