简体   繁体   English

在等待另一个站点的值时显示或隐藏div元素

[英]Showing or hiding div elements while waiting for a value from another site

In PHP, is it possible to use conditions that will display either one of two div elements? 在PHP中,是否可以使用显示两个div元素之一的条件? My pseudocode: 我的伪代码:

//in Site 1
$tokenFromSite1 = 'xxx';
$tokenFromSite2 = '';
while($tokenFromSite1 != $tokenFromSite2){
    //show div containing Connect button;
    clickConnect(); //includes $tokenFromSite1 value as URL param "token" and opens a new tab to Site 2
        //in Site 2
        //gets $tokenFromSite1 value and opens a URL containing this value as param "token" and redirects to site 1
    //back to Site 1
    $tokenFromSite2 = //GET value of param "token"
}
//div containing Connect button disappears and shows a div that says "Connected"

I am not sure if my logic is correct, and how exactly is Site 1 going to "wait" for the token value from Site 2. Also, how do I hide/show div elements? 我不确定我的逻辑是否正确,以及站点1将如何“等待”站点2中的令牌值。此外,如何隐藏/显示div元素?

It's not possible. 这是不可能的。 PHP is compiled server side. PHP是在服务器端编译的。 It will run the full script and then output the results. 它将运行完整的脚本,然后输出结果。 In order to achieve what you want you will need a jQuery code that uses AJAX. 为了实现您想要的,您将需要一个使用AJAX的jQuery代码。 Because it's a client side script it can interact with the user's screen after the page is loaded. 由于它是客户端脚本,因此可以在页面加载后与用户的屏幕进行交互。

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

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