JQuery, AJAX: Trying AJAX for the first time but cant get this to work...

Posted by fwaokda on Stack Overflow See other posts from Stack Overflow or by fwaokda
Published on 2010-12-24T21:51:31Z Indexed on 2010/12/24 21:53 UTC
Read the original article Hit count: 166

Filed under:
|
|

Trying to get the code below to work but the success doesn't execute - the error does. How can I get more detailed information on what is exactly going wrong? I'll include the code for next.php in a pastebin link also. Thanks. [next.php: http://pastebin.com/Gnu2AfU8 ]

$("a#next").click(function()
{
    $.ajax({
           type : 'POST',
           url  : 'next.php',
           dataType : 'json',
           data     : { nextID : $("a#next").attr("rel") },
           success  : function ( data ) {
                      $("img#spotlight").attr("src",data.spotlightimage);
                      $("div#showcase h1").text(data.title);
                      $("div#showcase h2").text(data.subtitle);

                      for(var i=0; i < data.size; i++)
                      {
                          $("ul#features").append("<li>").text(data.feature+i).append("</li>");
                      }

                      $("div#showcase p").text(data.description);

                      for(i=1; j < data.picsize; i++)
                      {
                          $("div.thumbnails ul").append("<li>").text(data.image+i).append("</li>");
                      }

                      $("a#next").attr("rel", $a("a#next").attr("rel") + 1);

           },
           error    : function ( XMLHttpRequest, textStatus, errorThrown) {
                     $("div#showcase h1").text("An error has occured.");
           }
    });
});

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery