I have a frame.php page
if(isset($_COOKIE['user'])){
// do some stuff
}else{
// login script
}
In a jquery.frame.php page
$("#infm_login_button").live("click",function(){
$.ajax({
url: "urltologinformacceptance",
type:"POST",
data: $("#login").serialize()
}).done(function(data){
//do stuff
});
return false;
});
Now in the same frame.php how do I make jquery tell, oh user has been logged in, yes go forward and go into the // do some stuff section. However, I do not want the user to refresh the page. I want it to just change the content from // login script to // do some stuff without refreshing the page, only when the user is logged in. Is there a way to make jquery talk to that frame.php and cookie?
Thanks!
First off: live is deprecated since jQuery 1.4 or something. Use .on() instead.
Secondly, you do not want to ‘do’ something when the ajax-call is done, but when it is a succes. What if there’s a time out? Try this:
This will print the output of you url.php to the entire document, sort of like include() in php.