views:

62

answers:

1
$('#com_form').submit(function(){

    var ele = $(this);

    $.post("includes/agenda_com.php",   
        {
            texte : ele.find('textarea').val(),
            id : ele.find('#agenda_id').val();
        },
        function(data){ 
            if(data=='foo') 
            {
                alert("Erreur ! votre commentaire n'a pas pu etre poste.");
            }
            else
            {
                ele.prev('#last').append(data);
                ele.find(':submit').attr('disabled','disabled');    
            }
        }
    );    

    return false;
});

well i'm using this code to post a text without reloading the page, but the return false; doesn't seem to work since the form actually submit the page to nowhere (cause i didn't put any action="somewhere" in my form code

+2  A: 

return false should work. If it's not, it usually means there's an error in your javascript. Try:

id : ele.find('#agenda_id').val()

instead of

id : ele.find('#agenda_id').val();
munch
Also there's no reason to do `ele.find` since you're finding an element with an id (which should always be unique on the page).
thenduks