php - pass multiple variable to bootstrap modal -


can pass multiple variable bootstrap modal?

here code :

p>link 1</p> <a data-toggle="modal" id="1" class="push" href="#popresult">test</a> <p>&nbsp;</p> <p>link 2</p> <a data-toggle="modal" id="2" class="push" href="#popresult">test</a> 

click links pop bootstrap modal

<div class="modal hide" id="popresult">   <div class="modal-header">     <button class="close" data-dismiss="modal">×</button>     <h3>modal header</h3>   </div>   <div class="modal-body" style="display:none;">     <p>some content</p>    </div>   <div class="modal-footer"> <a href="#" class="btn" data-dismiss="modal">close</a> <a href="#" class="btn btn-primary" >view full result</a> </div> </div> 

here ajax code :

$(function(){    $('.push').click(function(){       var id = $(this).attr('id');         $.ajax({           type : 'post',            url : 'yourscript.php', // in here should put query            data :  'post_id='+id, // here pass id via ajax .                      // in php should use $_post['post_id'] value         success : function(r)            {               // can show output in modal                $('#mymodal').show();  // put modal id               $('.modal-body').show().html(r);            }       });    }); }); 

ajax code post variable php file yourscript.php

<?php  session_start();      $_session['myid'] = $_post['post_id'];      echo $_session[myid]; ?> 

how can pass multiple variables yourscript.php?

you can pass multiple variables

var param1 = 2; var param2 = 5;  var data = 'param1='+param1+'&param2='+param2;  $.ajax({          type: "post",          url: "yourscript.php",          data: data,          success: function(html){           }        }); 

see example if want more data <a> tag instead of getting id


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -