My AJAX seems like not working. It should load patient details into a dropwdown.
this is my ajax code:
function PopulatePatient()
{
$("#PatientDropDown").empty();
$("#PatientDropDown").append("<option>Loading.....</option>");
$.ajax({
type:"POST",
url:"../listener/populatePatientName.php",
contentType:"application/json; charset=utf-8",
dataType:"json",
success: function(data){
$("#PatientDropDown").empty();
$("#PatientDropDown").append("<option value=''>-Select Patient-</option>");
$.each(data,function(i,item)
{
$("#PatientDropDown").append('<option value="'+ data[i].patientUserId +'">'+ data[i].patientFirstName +'</option>');
});
},
complete: function()
{
}
});
}
This is my PHP Code (populatePatientName.php):
<?php
include '../core/init.php';
$sql = mysql_query("SELECT patientUserId,patientFirstName FROM patientdetails");
if(mysql_num_rows($sql))
{
$data=array();
while($row=mysql_fetch_array($sql))
{
$data[]=array
(
'patientUserId' => $row['patientUserId']
'patientFirstName' => $row['patientFirstName']
);
}
header('Content-type: application/json');
echo json_encode($data);
}
?>
This is my HTML Code:
<select class="form-control" id="PatientDropDown">
</select>
This code works in my friend PC. My database and query are running well. Table contained data.
My code stop at this point : $("#PatientDropDown").append("Loading.....");
It does not enter ajax. Any solution?