简体   繁体   中英

How to fire a jquery function from another page without page refresh?

I have following paypal button in one of the page but at the start, its hidden. lets say page1.php

                <div id="over" style="display:none;">
                <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
                <input type="hidden" name="cmd" value="_s-xclick">
                <input type="hidden" name="hosted_button_id" value="'.$webinar_paypal_link.'">
                <input type="hidden" name="custom_name" value="'.$post_id.'">
                <input type="hidden" name="notify_url" id="notify_url" value="ipn_get.php?action=ipn">
                <input type="image" class="paypalbutton" src="" border="0" name="submit" alt="JOIN OUR SUCCESS TEAM NOW">
                <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
                </form>                         
                    </div>

And in the admin, i have a interface where admin can choose whether to display button yes or no and information is stored in database. So at that time, when admin choose yes, i want to show paypal button on page1.php (means change style="display:block from style="display:none;") without page refresh.

IS that possible?

It is impossible to do with jQuery alone, client-side (no requests to the server). It is possible using Websockets .

Is it worth the complexity in your case? Probably not. I would advise just polling the server client-side for updates. The addition in load will likely be negligible unless your application can't handle simple GET requests and has many, many concurrent users.

Edit: I'm wrong. You can use cookies for this purpose . But I don't think it's worth it when comparing that technique to using a well-known pattern like polling the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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