Reputation: 1749
I am trying to send json string to the server using jquery ajax, as below. It decodes correctly when GET is used, but does not work when POST is used. Any suggestions?
$.ajax({
type: "GET",
url: "../pssops21/php/insertTempTransData.php",
data: 'data=' + strSelectedItems,
dataType: 'json',
async: false,
success: handleresponse
});
Server side php:
$json = json_decode(stripslashes($_POST['data']), true);
After the comments, I realize it is not an ajax post issue, but a decoding issue.
Thank you.
Upvotes: 0
Views: 2068
Reputation: 10880
i think on the server side you need to have $_POST['strSelectedItems'] instead of $_POST['data'] .. or do a print_r($_POST) to get a clearer picture , i think the js is ok, but i am not a jquery expert.
Upvotes: 2