views:

108

answers:

2

There is a debugging syntax error, but I can’t see it! im a bit of a newbie, so excuse my code!!

$(document).ready(function(){
     /* fetch elements and stop form event */
     $("form.follow-form").submit(function (e) {
        /* stop event */
        e.preventDefault();
        /* "on request" */
        $(this).find('i').addClass('active');
        /* send ajax request */
            $.ajax({
                type: "POST",
                url: "ajax_more.php",
                data: $(this).serialize(),
                cache: false,
                success: function(html){
                    $("ul.statuses").append(html);
                    $("form.follow-form").remove();
                }
            });
            else {
                $(".morebox").html('The End');
            }
            return false;
     });
});
+10  A: 

You’ve got an else, but no if.

Here’s the code with some proper indentation — indentation makes the code much easier to understand, so you spot errors more quickly.

$(document).ready(function(){

    /* fetch elements and stop form event */
    $("form.follow-form").submit(function (e) {

        /* stop event */
        e.preventDefault();

        /* "on request" */
        $(this).find('i').addClass('active');

        /* send ajax request */
        $.ajax({
            type: "POST",
            url: "ajax_more.php",
            data: $(this).serialize(),
            cache: false,
            success: function(html){
                $("ul.statuses").append(html);
                $("form.follow-form").remove();
            }
        });


======> /* HERE’S THE ELSE WITHOUT AN IF */

        else {
            $(".morebox").html('The End');
        }

        return false;
    });

});
Paul D. Waite
+2  A: 

Try this

$(document).ready(function() {
    /* fetch elements and stop form event */
    $("form.follow-form").submit(function(e) { /* stop event */
        e.preventDefault(); /* "on request" */
        $(this).find('i').addClass('active'); /* send ajax request */
        $.ajax({
            type: "POST",
            url: "ajax_more.php",
            data: $(this).serialize(),
            cache: false,
            success: function(html) {
                $("ul.statuses").append(html);
                $("form.follow-form").remove();
            }
        });
        $(".morebox").html('The End');
        return false;
    });
});​
JapanPro
this works for me!!, well apreciated!! :))
getaway
you are welcome, happy to see you happy :)
JapanPro