Passing PHP variables to a jQuery Modal window
Hey Guys, I am new to jQuery and am not experienced with it at all...
Basically my goal is to have a modal popup with php variables passed to it...
for example - EITHER load a popup php page, view_details.php?id=1
OR
pass the php variables directly to the modal for the specified id.
I hope my question is not too开发者_如何学Python confusing and is understandable, any advice would be recommended. I currently have jqueryUI installed, but am open to using any module.
Greg
Ok so:
$('<div>').load('something.php').dialog();
And voila you have your dialog :-)
You might also want check out json datatype so youcould iterate over list of variables.
$.ajax({
url: 'request.php',
data: {'getParam1': 'foo', 'getParam2': 'bar'},
dataType: 'json',
success: function(response) {
$div = $('#myDiv'); //Id for your div
$.each(response, function(k, v) {
$div.append(v);
});
$div.dialog();
}
});
request.php
<?php
$variables = array(
'variable1',
'variable2',
'variable3',
'param1: '.$_GET['getParam1'],
'param2: '.$_GET['getParam2']
);
echo json_encode($variables);
?>
$('#modalDivID').load('view_details.php?id=1').dialog();
view_details.php
<?php
$id=$_REQUEST['id'];
echo 'This is popup #'.$id;
?>
精彩评论