jQuery: AJAX call isn't updating page

Posted by Cortopasta on Stack Overflow See other posts from Stack Overflow or by Cortopasta
Published on 2010-06-14T20:30:31Z Indexed on 2010/06/14 20:42 UTC
Read the original article Hit count: 237

Filed under:
|
|
|

Thought I had a simple AJAX call using $.POST(), but apparently my function isn't firing, and nothing is updating :-/

Here is the call:

 $(".answerVerse ul li").click(function(){
    var rank = $(this).removeClass("star_empty star_full star_highlight").attr("class");
    var verse_id = $(this).parent().parent().find(".verseId").html();
    var answer_id = $(this).parent().parent().find(".answerId").html();
    var place = this;
    $.post("rank.php", { rank: rank, verse_id: verse_id, answer_id: answer_id },function(data){
      $(place).parent().removeClass().addClass(data.newVerseRank);
      for (i=0;i<=5;i++)
        {
        $(".answerVerse ul."+i).each(function(){
          $(".answerVerse ul."+i+" li."+i).prevAll().andSelf().removeClass("star_empty").addClass("star_full");
          });
        }
      }, "json");
    });

And here is the PHP (rank.php) that it calls:

require_once("dbcon.php");
$user = new user();
$user->updateVerseRank($_POST['verse_id'], $_POST['rank']);
$user->getVerse($_POST['verse_id']);
$user->getAnswer($_POST['answer_id'];
$arr = array ('newVerseRank'=>htmlspecialchars(round($user->verse[3])),'newVerseVotes'=>htmlspecialchars(round($user->verse[4])),'newAnswerRank'=>htmlspecialchars($user->answer[3]));
echo json_encode($arr);

Why am I not updating the page? I know it's something dumb I'm doing seeing as how this is my first attempt at AJAX and JSON :-/ Just trying to learn

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery