Very weird jquery/json problem...

Posted by Scarface on Stack Overflow See other posts from Stack Overflow or by Scarface
Published on 2010-04-18T06:07:00Z Indexed on 2010/04/18 6:13 UTC
Read the original article Hit count: 137

Filed under:
|
|

Hey guys I have finally located the cause of this problem...I just have no idea how to fix it and why it is happening. I have a jquery getjson function and it returns 0 results every 2-5 clicks on new topics or refreshes. For some reason if I change my query to sort results by ASC it always returns results and much quicker, but this poses a problem since I need results by DESC. If anyone has any ideas, I would greatly appreciate it because I am dumbfounded at this point. Here is my query but I need it by DESC

SELECT time, user, message FROM comments WHERE topic_id='$topic_id' ORDER BY time ASC LIMIT 10

  $.getJSON(files+"comments.php?action=view&load=initial&topic_id="+topic_id+"&t=" + (new Date()), function(json) {
            if(json.length) {
              for(i=0; i < json.length; i++) {
                $('#comment-list').prepend(prepare(json[i]));
                $('#list-' + count).fadeIn(1500);
              }

            }

          });

I return results like so

while($row = mysql_fetch_array($res)){
$data[] = $row;
}
  $out = json_encode($data);
  print $out;

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about mysql