Search code examples
phpjqueryjquery-post

jquery post form


I have this code for send simple data using jquery , but no works , all time reload de page and no load contents i send by post

My code it´s this :

<script>
$(document).ready(function() {

    $("#form_order").submit( function () {    
        $.ajax({   
            type: "POST",
            data : $(this).serialize(),
            cache: false,  
            url: "indexer_adm.php?send_order2=ok",   
            success: function(data){
                $("#load_order").html(data);                          
            }   
        });   
        return false;     
    });
</script>

<form name="forma" id="form_order" method="post" action="">
<table width="100%" border="1">
<tr>
<td height="30" align="center" valign="middle">
<select name="select_order">
<option value="articles">Articles</option>
<option value="blogs">Blogs</option>
<option value="products">Products</option>
</select>
<input type="submit" name="Submit" value="Acceder">
<input type="hidden" name="send_order2" value="ok"> 
<input type="hidden" name="action_load" value="<?php echo $_REQUEST['action_load'];?>">
</td>
</tr>
<tr>
<td height="30" align="center" valign="middle">&nbsp;</td>
</tr>
</table>
</form>

<div id="load_order"></div>

In the div called load_order , it must load the result of this send by post from the form , but the page reload and no works , i see the code many times but i don´t understand what happen

Thank´s for All


Solution

  • There is a syntax error in your code, you haven't closed the submit handler.

    $(document).ready(function() {
        $("#form_order").submit( function () {    
            $.ajax({   
                type: "POST",
                data : $(this).serialize(),
                cache: false,  
                url: "indexer_adm.php?send_order2=ok",   
                success: function(data){
                    $("#load_order").html(data);                          
                }   
            });   
            return false;     
        }); // <---
    });