0
我在這裏做錯了什麼?一切正常,並有在控制檯中沒有錯誤,但也有沒有控制檯日誌說它成功與腳本如何使用ajax輸入一個javascript變量到php函數中?
索引文件:
<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);
?>