PHP As you can see i have define all the script correctly but ajax is not working and no status messege is showing on data success.the error is Uncaught syntaxx error
$type=get_safe_value($_POST['type']);
if($type=='password'){
$old_password=get_safe_value($_POST['old_password']);
$new_password=get_safe_value($_POST['new_password']);
$check=mysqli_num_rows(mysqli_query($conn,"select * from lab_details where password='$old_password'"));
$res=mysqli_query($conn,"select password from lab_details where id='$lid'");
$row=mysqli_fetch_assoc($res);
$dbpassword=$row['password'];
if(password_verify($old_password,$dbpassword)){
$new_password=password_hash($new_password,PASSWORD_BCRYPT);
mysqli_query($conn,"update lab_details set password='$new_password' where id='$lid'");
$arr=array('status'=>'success','msg'=>'Password has been updated');
}else{
$arr=array('status'=>'error','msg'=>'Please enter correct password');
}
echo json_encode($arr);
}
?>
**HTML CODE**
html code here
<form id= "frmPassword" method="POST"
enctype="multipart/form-data">
<!-- Clinic Info -->
<div class="card">
<div class="card-body">
<h4 class="card-title">Change Password</h4>
<div class="row form-row">
<div class="col-md-12">
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" name="old_password" id="labname" value="">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>confirm Password</label>
<input type="password" class="form-control" name="new_password" value="">
</div>
</div>
</div>
<div class="submit-section submit-btn-bottom">
<button type="submit" class="btn btn-primary submit-btn" id="password_submit">Save Changes</button>
</div>
</div>
<input type="hidden" name="type" value="password">
<div id="password_form_msg"></div>
</div>
</div>
</form>
</div>
AJAX SCRIPT here you can see the script i have passed data using jQuery.parseJson(result)
<script>
jQuery('#frmPassword').on('submit',function(e){
jQuery('#password_submit').attr('disabled',true);
jQuery('#password_form_msg').html('Please wait...');
jQuery.ajax({
url:'update_lab_profile.php',
type:'post',
data:jQuery('#frmPassword').serialize(),
success:function(result){
jQuery('#password_form_msg').html('');
jQuery('#password_submit').attr('disabled',false);
var data=jQuery.parseJSON(result);
if(data.status=='success'){
swal("Success Message", data.msg, "success");
}
if(data.status=='error'){
swal("Error Message", data.msg, "error");
}
}
});
e.preventDefault();
});
</script>
- i think i am missing something here in jQuery.parseJSON *