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.
我认为在服务器端,您需要$ _POST ['strSelectedItems']而不是$ _POST ['data'] ..或执行print_r($ _ POST)以获得更清晰的图片,我认为js可以,但是我不是jQuery专家。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.