Reputation: 219
I need to post JSON data into a raw text format. I can post like key value pair. But fails to post like raw text format.
var clientslist = new ClientsList();
clientslist.fetch({
data: $.param({data:'{"uid":19 ,"pn":0 }'}),
type: 'POST',
dataType: 'json'
});
Note that clientlist()
is to server.
From the above code I can post JSON {"id":123 ,"fl":0 }
in data key value. From server I can get it like php code $_POST['data']
.
But for me it is just need to send the JSON {"id":123 ,"fl":0 }
because from server it receive using php code file_get_contents("php://input");
How do I solve this?
Upvotes: 1
Views: 208
Reputation: 17168
var clientslist = new ClientsList();
clientslist.fetch({
data: JSON.stringify({ uid: 19, pn: 0 }),
type: 'POST',
dataType: 'json',
contentType: 'application/json',
processData: false
});
Upvotes: 2