Reputation: 1836
Something strange happens: when i want to post a string "??" via ajax to the server
$.ajax({
type: 'POST',
url: path,
dataType: 'json',
data: JSON.stringify({
text: "??"
})
});
it allways produces something like that in request to the server:
{"text":"jQuery21109622253710404038_1411696744993"}:
What is happening here? What the problem with double ? ?
Upvotes: 0
Views: 138
Reputation: 423
Do not use JSON.stringify for data. It should work fine after removing that. See the code below.
$.ajax({
type: 'POST',
url: 'http://localhost/rnd/ajax.php',
dataType: 'json',
data: {text: "??"}
});
Upvotes: 0
Reputation: 12300
You need to specify the content type;
$.ajax({
type: 'POST',
url: path,
dataType: 'json',
contentType: 'application/json; charset=utf-8', //<--This line
data: JSON.stringify({
text: "??"
})
});
Check this similar question
Let me know if it works
Upvotes: 1