Hello i am a new coder and having first experience with JSON. I am getting values from database in php file and want to send them in javascript file using JSON object. But the problem i am facing is that i am not getting into the $.getJSON function. Here is json code in javascript file:
$(document).ready(function(){
$.getJSON("php/personal_profile/get_DoctorInfo.php", function (data) {
alert("Hello"); //NOT showing any output on the webpage.
if (data.login_status)
{
$('.doctor_profile').show();
$('#name').value(data.Name);
$('#speciality').value(data.speciality);
$('#p_checked').value(data.p_checked);
$('#p_pending').value(data.p_pending);
}
else
{
alert("You are not Logged In!");
}
});
});
In PHP file, I am just getting values from the database and trying to send them in javascript file using json_encode() function.
echo json_encode(array('login_status' => true , 'Name' => $name , 'speciality' => $speciality , 'department' => $department , 'p_checked' => $patients_checked , 'p_pending' => $patients_pending));
Please help me .. M stuck here.. If i use
$.get("path",function(object){alert("hello")});
it works but when i use
$.get("path",function(object){alert("hello")}, "json");
then it doesn't work.