I'm having trouble displaying the value from the success function of my Ajax call. My code is as follows.
$.ajax({
type: "POST",
url: "http://localhost/practical 8/checkuser.php",
data: form_data,
success: function(response)
{
if(response == 'success'){
$("#errorUsername").html("<label class='error'>"+response+"</label>");
}else if(response == 'fail'){
$("#errorUsername").html("<label class='error'>"+response+"</label>");
}
}
});
My checkuser.php is basically echos "succcess" or "fail".
Mine ifand elseif the instructions in my function of success do not work. But do
$.ajax({
type: "POST",
url: "http://localhost/practical 8/checkuser.php",
data: form_data,
success: function(response)
{
$("#errorUsername").html("<label class='error'>"+response+"</label>");
}
}
});
works great. What am I doing wrong?
source
share