Solution to report undefined a error when using jquery

When the project uses easyUI, the foreground reports an error, type error: A is undefined. I see that the error location is actually the source code of JQ… It’s impossible. I searched a lot of information on the Internet, but I didn’t solve the problem. After nearly a month’s thinking, I seem to have found the cause of this problem. It may not be right. It only represents personal profile. If there is a positive solution, please let me know. Thank you.

The error screenshot is as follows:

The reasons are as follows: I have such a piece of code in JS:

 $('#cargo_info').datagrid().datagrid('getPager');

Note that this code is not put in any function, nor is it wrapped with $(function () {}). Just this sentence is put directly in JS code. This is all the cases that report this error in my project. My preliminary analysis is because JS thinks that there is no method to call this sentence, so it reports an error.

Solution: wrap the isolated statements in JS with $(function () {}), or write them in a function,

<pre name="code" class="javascript">$(function(){
    $('#cargo_info').datagrid().datagrid('getPager');
})


Like this, you can’t make a mistake at the front desk

Read More: