[英]load external js file into bootstrap modal box
我需要在引導模態框中顯示google map。 我在頁面中從Google網站加載了Google Map API,並且模式框正常工作。 像這樣 :
<script src="http://maps.google.com/maps/api/js?sensor=false&libraries=places"></script>
HTML:
<a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a>
現在,我需要在模式框的鏈接(啟動模態)單擊后從URL加載google map api( .JS File
/ Libraries
)。 如何創建呢?
如果您使用的是jQuery,則可以使用jQuery.getScript()
方法: http : jQuery.getScript()
基本用法:
$.getScript( "ajax/test.js", function( data, textStatus, jqxhr ) {
console.log( data ); // Data returned
console.log( textStatus ); // Success
console.log( jqxhr.status ); // 200
console.log( "Load was performed." );
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.