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