I need to display checkbox that binds dynamically using ajax and php .
my code is
<?php
include 'dbconnect.php';
$result = mysqli_query($link, "SELECT * FROM city where district_id='$dist' ");
while($city_row=mysqli_fetch_array($result)){
?>
<input type="checkbox" value="<?php echo $city_row['id']; ?>"/><?php echo $city_row['city_name']; ?>
<?php
}
}
?>
ajax script
$.ajax({
type: "POST",
cache: false,
url: "get_locality.php",
data:{districts:hi },
success: function(response){
alert(response);
$('#city').html(response);
}
});
html div
<div class="checkbox" ><span id="city">
</span>
</div>
but it only displays the values . not displaying the checkboxes
$distwhere is that defined?districts:hiwhere are those defined?