【发布时间】:2015-11-25 16:36:33
【问题描述】:
我需要将动态数据加载到引导模式框中。
JS:
$(function() {
$('.push').click(function() {
var id = $(this).attr('id');
$.ajax({
type: 'post',
url: '../controller/booksdetails.php', // in here you should put your query
data: 'cmid=' + id, // here you pass your id via ajax .
// in php you should use $_POST['post_id'] to get this value
success: function(r) {
// now you can show output in your modal
$('#cm').modal({
backdrop: 'static',
keyboard: false
}) // put your modal id
$('.something').show().html(r);
}
});
});
});
PHP 文件:
if(isset($_POST['cmid'])){
$DB = mysqli::f("SELECT * FROM " . BOOKS . " WHERE id = ?",filter_var($_POST['cmid'], FILTER_VALIDATE_INT));
print_r($DB);
}
和打印数据到模态框div和class="something"。此方法真正有效,并且 打印 所有 php 数组结果。
现在我需要使用 php 数组 aftar 将数据加载到 modalbox(使用 php 类、安全数据……)。我的意思是:load php 数据到 modalbox(即:json)不打印 结果到 modalbox。
我怎样才能生成这个?
【问题讨论】:
标签: javascript php jquery mysql twitter-bootstrap