Pass variable to frame via loadData in Bpopup

1.8k views Asked by At

I, i need to pass a value to ajax iframe, i using loadData method of Bpopup to this.

The problem is this: don't know how i pass variable to target ajax frame, so when the modal show, catch that value and process it via jQuery

if someone have experience using Bpopup, please help in this case, because Bpopup is a excelent modal and i using in my actual project, this is a url detailed about Bpopup API

http://webcache.googleusercontent.com/search?q=cache%3Adinbror.dk%2Fblog%2F&oq=cache%3Adinbror.dk%2Fblog%2F&aqs=chrome..69i57j69i58.1553j0j4&sourceid=chrome&espv=210&es_sm=122&ie=UTF-8

PS: when i wrote this note, this direction was offline http://dinbror.dk/blog/bpopup

Actualizacion:

the website is currently ONLINE, pleasy dont calify negative without reason, comment please

1

There are 1 answers

0
bishop On

I agree with @rsurjano, bPopUp() is a clever API and very helpful. I experienced the same predicament until I discovered how to use the loadData function via plugin inspection.

As you may have noticed bPopUp() can take in option arguments, for full reference go to:

http://dinbror.dk/blog/bPopup/

the loadData works with three other arguments i.e.

  1. content //default is ajax - how data will be loaded, also takes iframe & img
  2. contentContainer // the name of the destination container - where data will be loaded
  3. loadUrl // the path to a data source - could be a php script with feed back or another html page

Here is what I did...

  1. HTML ...within your html body tag

    <button id="showModal">click me</button>
    
    <div id="my_modal" style="display:none">
    
    </div>
    
  2. JavaScript

    $("#showModal").click(function(){
        var post_data = {myname:"munyaradzi ranga"};
        $('#my_modal').bPopup({
            content: 'ajax',
            contentContainer: '#my_modal',
            loadData: post_data,
            loadUrl: 'get-data.php'
        });
    });
    
  3. PHP

    <?php
        $name = $_POST['myname'];
        echo "<p>Hello $name<p>";
    ?>
    

PLEASE NOTE!!! 1. I didn't go through the normal stuff like PHP security. 2. Make sure your references to the external source files e.g bPopUp.js is valid, the code will obviously won't work if your paths are not correct.