我在这做错了什么?一切正常,控制台没有错误,但也没有控制台日志说它成功了
带脚本的索引文件:
<script type="text/javascript">
function upVote(picNum)
{
var pictureNumber = parseInt($("#" + picNum).attr("id"));
$.ajax({
url: "upload/pics/changeVote.php",
data: {"picNum":pictureNumber},
type:'post',
dataType:'json',
success: function(output_string){
PictureNumber = output_string['picturenumber'];
alert(PictureNumber);
}
});
var currentVote = parseInt($("#" + picNum).attr("value"));
alert("pictureNumber is " + pictureNumber + "and currentVote is " + currentVote); //here to help me, no functionality
$newVote = currentVote + 1;
alert($newVote); //here to help me
}
</script>
/upload/pics/changeVote.php
<?php
$picNum = $_POST['picNum'];
function otherFileFunc($pic){
$final = $pic + 1;
return $final;
}
$outputnumber = function($picNum);
$array = ('picturenumber' => $outputnumber);
echo json_encode($array);
?>
答案 0 :(得分:2)
错误 /upload/pics/changeVote.php
$outputnumber = function($picNum);
必须是:
$outputnumber = otherFileFunc($picNum);
您无法使用function()
,您应该使用功能名称。