MEDANIS
MEDANIS

Reputation: 117

How to execute js / jquery code after php page has loaded

I'm calling a php page using a jquery command, this php page will make some sql queries after that it update a cookie value...I want to get this value but only after all the php page has done the full job...I'm using this code right now to call the php page:

$(".emptyBox").load("gettingTime.php");
var setTime = readCookie("timeNow");

The problem in this code is that he load the php page but he does not wait untill in finish it work so the setTime variable it gets the value of the previous php page call...I want it to wait untill the php page finish successfully then it reads the cookie.

Upvotes: 1

Views: 135

Answers (1)

charlietfl
charlietfl

Reputation: 171669

Use the complete callback of load()

var setTime

$(".emptyBox").load("gettingTime.php", function(){
   // new html has been loaded here
   setTime = readCookie("timeNow");
});

Upvotes: 1

Related Questions