-2

The problem:

I have a series of 'accept' buttons, on click it opens a lightbox (a modal- using bootstrap), of course this is done without refreshing the page.

On the lightbox I need to show information regarding what is being accepted (therefore I need to pass a PHP variable to the lightbox). So the problem is how can I pass on a variable on click without refreshing the page? I tried using javascript, but the thing is once I set up a variable in JS I can't get that variable to PHP without refreshing the page.

The button has this code.

<a href="#modal-accept" data-toggle="modal"><button class="btn btn-acceptColor m-t-lg">Accept</button></a>

The other code isn't relevant for the purpose of this question. I just need the concept of how to actually do it.

Any help!?

Alex
  • 9
  • 5
  • @tymeJV thought so, I'm not that familiar with it though, do you have any examples of how to do it with AJAX? – Alex Dec 24 '13 at 05:52
  • see examples http://api.jquery.com/jQuery.post/ –  Dec 24 '13 at 05:54

1 Answers1

0

there are many examples. I provides some links, you can use them in your code as you suitability..

1). Ajax Tutorial
2). jQuery Ajax POST example with php
3). jQuery Ajax POST example with php
4). show data in lightbox
5). How to add jquery lightbox to content added to page via ajax?

I hope above links helpful for you

       $(".btn-acceptColor").click( function (){
        var person = {
        name: $("#id-name").val(),
        address:$("#id-address").val(),
        phone:$("#id-phone").val()
    }

$.ajax({
                  type: "POST",
                  url: "exaple.php",
                  data: person,
                  success: function(msg) {
                      var msg = $.parseJSON(msg);
                      if(msg.success=='yes')
                      {
                         return true;
                       // fill you light-box form get value from example.php page 
                     }
                     else
                     {
                        alert('Server error');
                        return false;
                    }
                   }
            });
       });
Community
  • 1
  • 1
Kushal Suthar
  • 423
  • 6
  • 21
  • yes if you provides some detail regarding to your question ... second thing is that where your actually data exist on server or your loaded page ..? – Kushal Suthar Dec 24 '13 at 06:30