【发布时间】:2014-01-17 16:13:03
【问题描述】:
我在jQuery 中有这段代码:(文件名是 javascript.js ...我之前使用的是 JavaScript...)
$(document).ready(function() {
$("#readFile").click(function() {
$.get('test.txt', function(data) {
$("#bottom_pane_options").html(data); // #bottom_pane_options is the div I want the data to go
}, 'text');
});
});
...在 HTML 中:
<!DOCTYPE html>
<html>
<head>
<title>Culminating</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./javascript.js"></script>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCJnj2nWoM86eU8Bq2G4lSNz3udIkZT4YY&sensor=false">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(50.569283,-84.378433),
zoom:5,
mapTypeId:google.maps.MapTypeId.TERRAIN
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div class="content">
<div id="googleMap"></div>
<div id="right_pane_results">hi</div>
<div id="bottom_pane_options">
<button id="readFile">Read File</button>
</div>
</div>
</body>
当我检查控制台时,我得到Uncaught ReferenceError 说$ 没有在第一行定义。我假设它指的是第一行的第一个字符。我从一个网站获得了这段代码,我是jQuery 的新手,所以我不确定这里出了什么问题。
有什么建议吗?
【问题讨论】:
-
你应该首先包含 jQuery
-
尝试在您的 html 内容末尾添加您自己的代码脚本,在您关闭
标签: javascript jquery html file-io