简体   繁体   English

php页面加载后如何执行js/jquery代码

[英]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:我正在使用 jquery 命令调用一个 php 页面,这个 php 页面会在更新 cookie 值之后进行一些 sql 查询......我想获得这个值,但只有在所有 php 页面都完成了全部工作之后.. .我现在正在使用此代码来调用 php 页面:

$(".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.这段代码中的问题是他加载了 php 页面,但他没有等到完成它的工作,所以 setTime 变量获取前一个 php 页面调用的值......我希望它等到 php 页面成功完成然后它读取cookie。

Use the complete callback of load()使用load()的完整回调

var setTime

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM