0
我目前在使用jQuery時遇到了一些麻煩。我試圖通過jQuery.get加載一些csv文件(即google.com),並構建一些圖。不知怎的,jQuery的只是無法加載文件properly.Here是我的代碼:jQuery沒有正確地獲取東西
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).keypress(function(e) {if(e.keyCode == 13) {updateData();};});
drawchart("2013.04.02")
function drawchart(date){
jQuery.ajaxSetup({async:false});
var sql = "http://www.andrewpatton.com/countrylist.csv";
console.log(sql);
var ans= jQuery.get(sql);
ans.done(...draw...);
ans.fail(console.log("fail"));
}
</script>
</head>
<body>
<input id="date-input" style=margin-left:160px type="text" id="date" name="date" />
<input type="button" value="submit" onClick="updateData();"/>
<p style=margin-left:160px> Date format: YYYY.MM.DD </p>
</body>
</html>
我已經測試過的URL,它確實返回我的.csv文件,當我在瀏覽器中輸入網址,所以我的猜測是有沒有什麼與jQuery,我不明白...
有人可以告訴我會發生什麼事嗎?
附註:爲什麼async設置爲false? – Dom 2013-04-03 19:23:03
我很確定這是你沒有正確地獲取東西,而不是jQuery?或者可能只是JavaScript的跨域策略。 – adeneo 2013-04-03 19:30:06
雅... jQuery很好..它只是我不知道發生了什麼.. – user1948847 2013-04-03 19:58:36