0

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?

  • If you want to show or disable the button in "real-time", there must be some kind of comunication. Either polling from the server every X seconds or making some kind of persistent connection maybe using [WAMP Proto](http://wamp-proto.org/). – Miguel G. Flores Sep 19 '16 at 19:21
  • @MiguelGonzalez i dont want to pull the server every x seconds it can increase a load on server resources. is there any other approach? – Mat Riexinger Sep 19 '16 at 20:46

1 Answers1

0

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.

Community
  • 1
  • 1
quercy
  • 78
  • 6