[問題] bootstrap引入custom js file失敗消失
各位大大好 小弟想問一下,
最近寫了一個jquery script作GoogleMap功能,
在blank html page開發時可以順利work,
功能搞定後把他pack成js file引入bootstrap template,
卻一直得到失敗
(如我用這個bootstrap template:
http://startbootstrap.com/template-overviews/grayscale/ )
//HTML script
<!DOCTYPE html>
<html>
<head>
<script>
<!-- my script here... -->
</scripn>
</head>
<body>
<section id="about" class="container content-section text-center">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div id="map-canvas"></div>
</div>
</div>
</section>
<!-- it works fine. -->
</body>
<footer>
<!-- JS include -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Plugin JavaScript -->
<script src="js/jquery.easing.min.js"></script>
<!-- Google Maps API Key - Use your own API key to enable the map feature.
More information on the Google Maps API can be found at
https://developers.google.com/maps/ -->
<script type="text/javascript"
src="" rel="nofollow">https://maps.googleapis.com/maps/api/js?key=AIzaSyCRngKslUGJTlibkQ3FkfTxj3Xss1UlZDA&sensor=false"></script>
<!-- Bootstrap Custom Theme JavaScript -->
<script src="js/grayscale.js"></script>
<!-- My custom JavaScript -->
<script src="js/custommap.js"></script>
</footer>
</html>
//custommap.js script
//寫好了幾個function然後用$(function() {});包起來
$(function() {
var x = [];
var list = [];
var map;
for(var s = 0; s < jsfile.length; s++) {
$.getJSON(jsfile[s], function(json) {
for(var i = 0; i < json.length; i++) {
x.push({
//push some info like name, latlng
});
}
});
}
//start navigator
function getUserGeolocation() {
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(parsePosition, noGeolocation);
} else { handleNoGeolocation(false); }
}
//success callback of getCurrentPosition and do map work
function parsePosition(pos) { ... }
//error callback of geolocation.getCurrentPosition
function noGeolocation() { handleNoGeolocation(true); }
function handleNoGeolocation(errorFlag) { ... }
});
然後我在firefox debug一直收到
SyntaxError: illegal character
}
或沒有成功display map...
是否在jquery包裝這寫錯還是我呼叫錯誤呢?
請大大解救!!
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.65.71.253
※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1423453420.A.607.html
→
02/09 23:36, , 1F
02/09 23:36, 1F
→
02/09 23:40, , 2F
02/09 23:40, 2F
→
02/09 23:41, , 3F
02/09 23:41, 3F
→
02/09 23:42, , 4F
02/09 23:42, 4F
謝謝大大的建議,我也是大概猜問題在包js那邊,只是不確定是不是...
下次排版會注意或貼到JS Bin轉過來好了,
其時拿掉也可以只是碰到問題就很想解出到底bug在哪...
前幾天突然發現在browser debug時 script竟然不會隨著我修改而update,
真抱歉完全沒想到會是vm的問題所以起初沒交代
我是用virtual box/vagrant作開發環境,
結果是踩到一個vagrant的一個bug
issue在這https://github.com/mitchellh/vagrant/issues/351
進入nginx.conf修改sendfile為off,問題解決!
※ 編輯: GTBUG (203.65.71.253), 02/17/2015 14:49:59