我的代码运行得很好,除了"userName“,因为某些原因,通过JSON发送一个字符串不会post到表中,它什么也不会发送。
有人能看到问题出在哪里吗?
jquery
lowestScoreId = 1;
userPoints = 50;
userName = "ted";
$.getJSON("functions/updateHighScores.php", {lowestScoreId: lowestScoreId, userPoints: userPoints, userName: userName}, function(data) {
$('#notes').text(data.userName); //for testing
}); php
lowestScoreId = json_decode($_GET['lowestScoreId']);
$userName = json_decode($_GET['userName']);
$userPoints = json_decode($_GET['userPoints']);
include 'config.php';
$currentTime = time();
mysql_query("UPDATE highScores
SET `name` = '$userName',
`score` = '$userPoints',
`date` = '$currentTime'
WHERE id='$lowestScoreId'");
echo json_encode(array("userName" => $userName)); // for testing发布于 2012-07-27 20:17:48
你为什么要用这个:
$userName = $obj = json_decode($_GET['userName']);它可以正常工作
$userName = $_GET['userName'];https://stackoverflow.com/questions/11687301
复制相似问题