Determine the status outside the ajax call. then access to it is everywhere.
var status = '';
$.ajax({
url: '/users/validatepassword/'+current,
async: false,
dataType: "json",
success: function(data){
status = data;
},
});
if(status == "Password correct")
{
}
In users / validatepassword use json_encode ()
echo json_encode("Password correct");
source
share