I have the following script which tries to send all the form data to login_processor.php
file.
<script>
$( document ).ready(function() {
$("#submit").click(function(){
var name = $("#name").val();
var email = $("#email").val();
var FD = new FormData($("#main");
if(name=="" || email==""){
$("#display").html("Please fill all fields");
}else{
$.ajax({
type: "POST",
url: "login_processor.php",
processData: false,
contentType: false,
data: FD,
success: function(result){
$("#display").html(result);
$("#display").fadeTo(2000, 500).slideUp(500, function(){
$("#display").slideUp(500);
});
}
});
}
return false;
});
});
</script>
My form got many text inputs, drop down menu, checkbox arrays etc. How can I get all the form values to my php file? For example, textbox values, selected dropdown values, selected checkbox values etc. With the above code, it is not working. I am not sure what am I doing wrong.Could someone help?
Edit 1
Issue found to be due to missing )
. But still it is not capturing my checkboxarray values. My checkbox as below. It is getting data from mysql database and showing as checkboxes
<?php
while($oaNamesQueryRow = mysqli_fetch_array($oaNamesQueryExecute)){
$oaName = $oaNamesQueryRow['oaName'];
echo '<div class = "checkbox-group" required style="float:left; margin-right: 25px;"><input class="checkBoxes" type="checkbox" name="checkBoxArray[]" value="'.$oaName.'" '; ?> <?php if(in_array($oaName,$_POST['checkBoxArray'])) echo "checked='checked'"; ?> <?php echo '> '.$oaName.'</div>';
}
?>