Problem solved
I've searched several sources of info for this kinda problems. But there's no solution exactly. The problem is I cannot pass the checkboxes value to div id with ajax. It keeps openning in a parent window. Here's my codes.
Javascript:
<script type="text/javascript"> $(document).ready(function() { $("#villa_submit").click(function() { var action = $("#villa_choose").attr('action'); //var form_data = { 'vid[]' : []};$("input:checked").each(function() {data['vid[]'].push($(this).val());}); var form_data = $('#villa_choose').serialize(); //suggested by Kev Price $.ajax({ type: "POST", url: action, data: form_data, beforeSend:function(){ $('#villa_result').html('<center><img src="/images/loading.gif" alt="Loading..." align="absmiddle"/> loading...</center>'); }, success: function(data){ $('#test_result').html(data); } }); return false; }); }); </script> HTML:
<form name="villa_choose" id="villa_choose" method="post" action=""> <input type="checkbox" name="vid[]" id="vid1" value="1" /> <input type="checkbox" name="vid[]" id="vid2" value="2" /> <input type="checkbox" name="vid[]" id="vid3" value="3" /> <input type="checkbox" name="vid[]" id="vid4" value="4" /> <input type="checkbox" name="vid[]" id="vid5" value="5" /> </form> <div id="test_result"></div>