Jquery-uncaught Referenceerror: $ is not defined error

Source: Internet
Author: User

These JS codes are available on my JSP page:

Load Data  $ (document). Ready (function () {  var param={};p Aram.page=3;param.size=10;$.post (home+ "/user/ Queryallinfo ", param,function (Result) {if (Result!=null && result.success) {var obj =result.rows;for (var i = 0; I & Lt Obj.length; i++) {var user =obj[i];var tr = "<tr><td>" + user. membername+ "</td>  <td>" + user. accountnumber+ "</td>  <td>" + user. Age+ "</td>  <td>" + user. gender+ "</td>  <td>" + user. birthday+ "</td>  <td>" + user. member_label+ "</td>"; $ (". Usertable"). Append (tr);}} Else{alert (result.msg);}}, "JSON")      ; function OnOK () {alert ("OK"); $ ("#loaddiv"). Text ("OK");}

When you visit this page,Google Chrome F12 will prompt uncaught Referenceerror: $ is not defined error and prompt is $ (document). Ready (function () {This is the wrong line 。

Conjecture: 1. The Jquery.js file version that was introduced does not match, after the replacement or error.

2. There is a conflict caused by other JS files that are imported.

3. Path error for Jquery.js file.

4. The problem of loading the JS file sequence, and put the jquery.js in the first place.

There are several ways to suggest an error.

Next, a OnOK () event is added to the page with $ ("#loaddiv"). Text ("OK"); Found this can be no problem, so think should not be jquery.js error.

Put the code in the OnOK function: the following

function OnOK () {alert ("OK"); var param={};p Aram.page=3;param.size=10;$.post (home+ "/user/queryallinfo", param,function (Result) {if (Result!=null && result.success) {var obj =result.rows;for (var i = 0; i < obj.length; i++) {var user =obj[i];var tr = "<t R><td> "+ user. membername+ "</td>  <td>" + user. accountnumber+ "</td>  <td>" + user. Age+ "</td>  <td>" + user. gender+ "</td>  <td>" + user. birthday+ "</td>  <td>" + user. member_label+ "</td>"; $ (". Usertable"). Append (tr);}} Else{alert (result.msg);}}, "JSON"); $ ("#loaddiv"). Text ("OK");}

The discovery did not appear before the uncaught referenceerror: $ is not defined error, but prompted 406 (not acceptable), Baidu after the 406 (not acceptable) to know The word used the @responsebody in controller control layer., to convert the object to JSON format, missing the conversion dependent jar package, and later added Jackson-xc-1.8.3.jar, Jackson-mapper-asl-1.9.2.jar Jackson-core-asl-1.9.2.jar, Jackson-jaxrs-1.8.3.jar, Json-lib-2.4-jdk15.jar These packages, the program runs normally.

JSON package Download: http://download.csdn.net/detail/u013147600/9023171



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Jquery-uncaught Referenceerror: $ is not defined error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.