This might be easy but I'm having trouble doing this right. How can I open a new page in the same window using jquery-ajax response?
As you can see I'm trying to display a custom text if the php response is equal to the word "invalid". If not open a new html page in the same window.
$("#lBtn").click(function(){
$.post("php/session.php",
{ username:$("#username").val(),
password:$("#password").val()
},
function(response) {
alert(response)
if(response == "invalid"){
$("#loginResponse").text("Error!!");
} else {
window.location = $(this).find('new/pahe.html').html();
}
});
});
Alert(response) shows the word "invalid" but the if statement does not work. Means neither it display Error!!
in $("#loginResponse")
nor it opens the new page. That's what I want to fix.