0

What am I doing wrong here?? Everything works fine and there are no errors in the console but there are also no console logs saying it succeeded

index file with script:

    <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

1 Answer 1

2

Mistake in /upload/pics/changeVote.php

$outputnumber = function($picNum);

has to be:

$outputnumber = otherFileFunc($picNum);

you can't use function(), you should use the function name instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.