A piece of JS code encountered a bug, due to the implicit global variable in the middle,
Because more code, through the Google Browser JS debugger to find the problem,
In any case, my computer can not be installed on the Fiefox, from the beginning of last year to try many times, have failed to end,
But Google's debugging is also very useful.
Simplify the code as follows:
Copy Code code as follows:
$ (function () {
var pageno = 2;//This parameter is variable
var pageSize = 10;
Test ();
Paginate (pageno,pagesize)//Because the test () method overrides PageNo, PageNo always equals 1
});
function Test () {
PageNo = 1;//global variable, overwriting previous PageNo, equivalent to writing Var pageno on the top of JS = 1
Change here to var pageno = 1; that's it.
Do,,,
}
function Paginate (pageno,pagesize) {
Window.location.href = "user_list.action?pageno=" +pageno+ "&pagesize=" +pagesize;
}
In JS recommended all variables are declared with Var, and all the variables can be written to the top, because JS does not block-level scope.