I have a form that submits using POST
and I want to covert it to an ajax submission of the form. When I use the .submit
function with the .ajax
function inside when I serialize the data fom the form is it going to be the same as just doing a POST
Some code:
<script type="text/javascript">
$("#optionsForm").submit(function(){
var data= $("#optionsForm").serialize();
$.ajax({
url: 'filter.php',
type: 'post',
data: data,
success: function(data){
alert(data);
}
});
return false;
});
</script>
<?php
$html = "";
$html .= "<div id='options'>";
$html .= "<form id='optionsForm' method='post'>";
foreach($selectValues as $key => $value){
$title=new MODEL\String($key);
$html.= "<fieldset class='optionsBox'>";
$html.= "<legend>".$title->friendlify()."</legend><br/>";
foreach($value as $option){
$html .= "<input type='checkbox' name='".$key."[]' value='$option'>".htmlspecialchars($option)."</input>";
}
$html.= "</fieldset>";
}
$html .= "</select><input type='submit' value='submit'></form></div>";
$html .= "<div id='tables'></div>";
Where I retrieve the data:
if(!empty($_POST)){
$filterValue=$_POST;
}
else{
$filterValue="y";
}