0

我需要从 .php 文件调用 twitter 模式窗口内的 html 数据。如何调用这个函数?下面的脚本在一个 php 文件中,一旦我们单击链接,我需要在模式窗口中调用它。我能够触发模态窗口但不能触发数据。

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title><?php echo $post->post_title; ?></title>
<meta name=”robots” content=”noindex”/>
</head>
<body>
<div style=”"><?php echo $image; ?></div>
<?php echo $post->post_title; ?></b>
<p style=”float: left;”&gt;Testing</p>
</body>
</html>
4

2 回答 2

0

您可以通过将 HTML 放入名为 的文件中来实现此目的remote.html,然后运行以下命令:

<a data-toggle="modal" href="remote.html" data-target="#modal">Click me</a>

或者,您可以使用 jquery 将 HTML 插入到模态窗口中,如下所示:

$('.modal-button').click(function() {

    var myHTML = "[YOUR HTML]";
    $('.modal-body').html(myHTML);

});
于 2013-09-12T17:47:59.323 回答
0

你想要的是在模态中显示图像和标题数据吗?

<div>
<div id="image"></div>
<span id="myTitle"></span></b>
<p style=”float: left;”&gt;Testing</p>
</div>

将此内容放在 modal 中并通过 ajax 调用获取图像和标题数据

  $(function () {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Fetch.php",//give the path of the php file or the function
                    data: '{ "query": ' + data + ' }',//place the query data
                    dataType: "json",
                    success: function (msg) {
                        AjaxSucceeded(msg);
                    },
                    failure: function (response) {
                        alert("Failure");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert("Error " + jqXHR + " " + textStatus.responseText + " " + errorThrown);
                    }
                });
            });

AjaxSucceeded(msg){
//replace the div with the image and the title
$(#image).innerHTML=msg.Image;
$(#myTitle).innerHTML=msg.Title;
}

干杯!!!

于 2013-09-12T17:58:30.643 回答