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