I have a string that looks like this
{ "name":"John", "age":30, "city":"New York"}
I want to post it to a PHP file exactly in the format as seen above, not as an array. The reason is that I will later use this string somewhere else, and I have no need to implode it or reformat it.
Here is what I have now.
var sentdata = '{ "name":"John", "age":30, "city":"New York"}';
$.ajax({
url: 'save.php',
type: 'post',
data: sentdata,
success:function(response){
console.log('Updated');
}
});
PHP is currently outputting this:
Array ( [{"name":"John","age":30,_"city":"New_York"}] => )
But I wanted a basic string that looks exactly like in sentdata
.
I prefer a Jquery/JSON solution, but if I have to do something in PHP then so be it.
Thanks!