簡體   English   中英

實現twitter bootstrap模態窗口調用html

[英]Implement twitter bootstrap modal window call html

我需要從.php文件中的twitter模態窗口內調用html數據。 如何調用此函數? 下面的腳本位於php文件中,一旦我們單擊鏈接,我需要在模式窗口中調用此文件。 我能夠觸發模式窗口,但不能觸發數據。

<html xmlns=”http://www.w3.org/1999/xhtml”>
<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;”>Testing</p>
</body>
</html>

您可以通過將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);

});

您想要的是在模式右側顯示圖像和標題數據?

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

將此內容放在模式中,並通過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;
}

干杯!!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM