I am getting response as standard id in my project & i need to pass this value to php variable any body help me.
My PHP page
<div class="checkbox check-success"> <?php
$b=mysql_query("select * from standard_names ")or die(mysql_error());
$count = mysql_num_rows($b);
$i = 0;
$breakafter=5; ?><?php
while($row = mysql_fetch_array($b))
{
$i++;
?>
<input type="checkbox" class="chkNumber" id="<?php echo $row['sn_id']; ?>" value="<?php echo $row['sn_id']; ?>" />
<label for="<?php echo $row['sn_id']; ?>"><?php echo $row['s_names']; ?></label>
<?php if($i % $breakafter == 0){?> <br><?php }
}
?> </div>
MY Jquery page
<script>
$(document).ready(function() {
$("#standardnameb").click(function(){
var standdis = $("#standdis").val();
if ($('.chkNumber:checked').length) {
var chkId = '';
$('.chkNumber:checked').each(function () {
chkId += $(this).val() + ",";
});
chkId = chkId.slice(0, -1);
}
else {
alert('Nothing Selected');
return false;
}
$.post("ajax.php",
{
standdis:standdis,
chkId:chkId
},
function(response){
if(response==0){
var str = "Inserted Successfully";
var result = str.fontcolor("green");
$("#disp4").html(result);
$("#ediths").hide();
}
else {
var str = "Already Inserted..! Please Edit Below ";
var result = str.fontcolor("green");
$("#disp4").html(result);
<!--$('#ramu').load(' #div1');
-->
$("#ediths").show();
}
});
});
});
</script>
and my ajax page
if(isset($_REQUEST['standdis']) && isset($_REQUEST['chkId'])){
$standdis=mysql_real_escape_string($_REQUEST['standdis']);
$chkId=mysql_real_escape_string($_REQUEST['chkId']);
$a=mysql_query("select * from st_name_assign_st_cat where s_id='$standdis' ")or die(mysql_error());
$row=mysql_num_rows($a);
if($row==0){
mysql_query("insert into st_name_assign_st_cat(s_id,sn_id,status,c_date) values ('$standdis','$chkId','0','$c_date')") or die(mysql_error());
echo "0";
}else{
echo $standdis;
}
}
Any body help me how to pass response to php variable dynamically