Uncaught ReferenceError:$在jQuery中没有定义错误

编程入门 行业动态 更新时间:2024-10-23 19:29:32
本文介绍了Uncaught ReferenceError:$在jQuery中没有定义错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 jQuery 中有这样的代码:(文件名是javascript.js ...我之前使用的是JavaScript)

I have this code in jQuery: (the file name is javascript.js ...I was using JavaScript before...)

$(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中:

...and this in 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="maps.googleapis/maps/api/js?key=AIzaSyCJnj2nWoM86eU8Bq2G4lSNz3udIkZT4YY&sensor=false"> </script> <script src="ajax.googleapis/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 的新手,所以我不确定这里出了什么问题。

When I check the console, I get the Uncaught ReferenceError saying that $ is not defined on the first line. I'm assuming that it is referring to the first character on the first line. I got this code from a website and I'm new to jQuery so I'm not sure what is going wrong here.

有什么建议?

推荐答案

您的脚本(首先是jQuery):

Change the order you're including your scripts (jQuery first):

<script src="ajax.googleapis/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript" src="./javascript.js"></script> <script src="maps.googleapis/maps/api/js?key=YOUR_APIKEY&sensor=false"> </script>

更多推荐

Uncaught ReferenceError:$在jQuery中没有定义错误

本文发布于:2023-06-04 08:35:12,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定义   错误   Uncaught   ReferenceError   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!