i having a drop down box, it have two client(ex:client,client),i have more then 2000 data in each client table ,when selecting client i want to retrieve all data from database and show it in front end that in HTML table with out refreshing can any one help me how to do that
my Dropdown code:
<select name="client" id="client" style="margin:-24px 0 0 1px;background-color:#E8E8E8;width:104px;position: absolute;">
<option value="">Select Client</option>
<?php
$sql=mysql_query("select * from client_list");
$clientid=$_GET['clientid'];
while($row=mysql_fetch_assoc($sql))
{
if(strlen($_GET['clientid'])>0 && $_GET['clientid']==$row['clientid']){
print' <option id="client" name="client" value="'.$row['clientid'].'" selected>'.$row['clientid'].' </option>';}
else{
print' <option id="client" name="client" value="'.$row['clientid'].'" >'.$row['clientid'].' </option>';
}
}
?>
</select>
Ajax
<script>
$(function() { document.ready
$("#client").on("change", function() {
var ID=$(this).attr('id');
var clientid=$("#client").val();
$.ajax({
type: "POST",
data: {
clientselect: $(this).val()
},
success: function(data) {
$("#display").html(data);
window.location = '?action=clientnetworkpricelist&clientid='+clientid+'';
$("#flash").hide();
}
});
});
});
</script>
You're missing the URL in the AJAX call:
$.ajax({
url: "server.php",
type: "post",
data: {
clientsel: $(this).val()
},
success: function(data) {
$("#display").html(data);
window.location = '?action=clientnetworkpricelist&clientid='+clientid+'';
$("#flash").hide();
}
});
server.php
should perform the appropriate database query, and output the HTML that you want to be put into the display
DIV.