On submit alert is working but inside ajax code not working. value store in var and go to ajax page where i trying to use mysql insert query but its not working properly. I after ajax success result is not display, For a sec ajax file name shows in NET (error console)
JQuery Code:
$(document).ready(function(){
$('#submit').click(function(){
var project_ID = $('#project_name').val();
var accommodation=$('#accommodation').val();
var no_of_floors=$('#no_of_floors').val();
var no=$('#no').val();
if(project_ID==''){
alert('Select Project Name');
}
if(accommodation==''){
alert('Select Accomodation Scale');
}
if($('#typeI').prop('checked')){
var type1=$('#typeI').val();
}
if($('#typeII').prop('checked')){
var type2=$('#typeII').val();
}
if($('#typeIII').prop('checked')){
var type3=$('#typeIII').val();
}
if($('#typeIV').prop('checked')){
var type4=$('#typeIV').val();
}
if(project_ID!="" && accommodation!='')
{
$.ajax({url:"villa_Accomo_type.php?project_ID="+project_ID
+"&accommodation="+accommodation+"&type1="+type1+"&type2="+type2
+"&type3="+type3+"&type4="+type4+"&no_of_floors="+no_of_floors+"&no="+no,
success:function(result){
res=result;
alert(res);
}
});
}
});
});
AJAX PAGE
<?php
$project_ID = $_GET['project_ID'];
$accommodation = $_GET['accommodation'];
$type1 = $_GET['type1'];
$type2 = $_GET['type2'];
$type3 = $_GET['type3'];
$type4 = $_GET['type4'];
$no_of_floors = $_GET['no_of_floors'];
$no = $_GET['no'];
echo $insert = "insert into villas_scale (project_id,scale,type,
no_of_floors,no) values('$project_ID',
'$accommodation','$type1','$no_of_floors','$no')";
mysql_query($insert);
echo $insert2 = "insert into villas_scale (project_id,scale,
type,no_of_floors,no) values('$project_ID',
'$accommodation','$type2','$no_of_floors','$no')";
mysql_query($insert2);
echo $insert3 = "insert into villas_scale (project_id,scale,
type,no_of_floors,no) values('$project_ID',
'$accommodation','$type3','$no_of_floors','$no')";
mysql_query($insert3);
echo $insert4 = "insert into villas_scale (project_id,scale,
type,no_of_floors,no) values('$project_ID',
'$accommodation','$type4','$no_of_floors','$no')";
mysql_query($insert4);
?>