2014-02-14 51 views
4

我有bootstrap模式數據遠程工作的所有瀏覽器除了鉻。背景顯示,但不是模式本身。引導模式數據 - 遠程在Chrome中不工作

parentPage.html

<a href="#" data-toggle="modal" data-target="#myModal"><img src="images/ball.gif" alt="Add Account"/></a> 
<div class="modal fade" id="myModal" tabindex="-1" data-remote="./popups/remotePage.html" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" > 
</div> 

remotePage.html

<div class="modal-dialog"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
     Header 
     </div> 
     <div class="modal-body"> 
      One fine body... 
     </div> 
     <div class="modal-footer">Footer 
     </div> 
    </div><!-- /.modal-content --> 
    </div><!-- /.modal-dialog --> 

我已經嘗試在<a>標籤將數據遠程。

我在想什麼?

回答

8

請改用此代碼。假設你正在使用Twitter的引導3

parentPage.html

<a href="./popups/remotePage.html" data-toggle="modal" data-target="#myModal"><img src="images/ball.gif" alt="Add Account"/></a> 
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" > 
<div class="modal-dialog"> 
    <div class="modal-content"> 
    </div> 
</div> 
</div> 

remotePage.html

<div class="modal-header">Header</div> 
<div class="modal-body"> 
    One fine body... 
</div> 
<div class="modal-footer">Footer</div> 

而且不要忘記,目錄結構是這樣的:

parentPage.html 
popups 
    remotePage.html 

更新

根據對答案的評論,谷歌Chrome不允許從文件協議(file://)作爲安全措施的XMLHttpRequest。你有兩個選項可用。

一個是你的文件託管在HTTP服務器。如果您使用的是Windows,請使用WAMP或XAMPP。

而第二個選項是關閉Chrome Web安全模式,但不建議這樣做

chrome.exe --disable-web-security 

供您參考:Allow Google Chrome to use XMLHttpRequest to load a URL from a local file

+0

是我使用Twitter的引導3,我仍然得到同樣的結果。在FF中運行良好,但在Chrome中運行得不錯。 – user3311026

+0

在parentPage.html的代碼上做了一個小小的編輯。另外,按Ctrl + Shift + I查看Google Chrome的Web Developer工具,看看Javascript中是否有錯誤。 –

+0

你是對的錯誤! – user3311026