In a recent project, you will not be able to debug JavaScript code when submitting to a child page, sometimes this problem, we can not normal in the browser, see our child page JavaScript code, so can only use the original alert or Console.log (), of course, this is a solution, but sometimes, we want to see how the program is actually running, but also can see what each parameter is exactly what value, so the meaning is relatively large.
I put a picture on it and you'll probably know when it's going to happen.
Copy Code code as follows:
<script>
function Stopwatchdog (watchdogid) {
Alert ("AA");
var url = ' <s:url value= '/watchdog/stopwatchdog '/> ';
var params = {
Watchdogid:watchdogid,
};
$.post (URL, params, function (data) {
if (data.success) {
Closedialog ();
Tbgrid.send ();
} else {
if (data.errormsg!= null && data.errormsg!= "") {
Jalert (data.errormsg, "system Message");
} else {
Jalert ("Stop Exception", "System Message");
}
$ ("#saveBtn"). Removeattr ("Disabled");
$ ("#saveBtn"). CSS ("Color", "white");
}
}, "JSON");
}
</script>
This is actually a function declaration, if you understand the JavaScript context, you know that the function declaration is only loaded when the page context load the function name, its function content can not load normally.
This problem can be solved if we change the function itself or define the function declaration in function autonomy.
Copy Code code as follows:
(function () {
function Stopwatchdog (watchdogid) {
alert ("AA");
var url = ' <s:url value= '/watchdog/stopwatchdog '/> ';
var params = {
Watchdogid:watchdogid,
};
$.post (URL, params, function (data) {
if (data.success) {
Closedialog ();
Tbgrid.send ();
} else {
if (data.errormsg!= null && data.errormsg!= "") {
Jalert (data.errormsg, "system messages");
} else {
Jalert ("Stop Exception", "System Message");
}
$ ("#saveBtn"). Removeattr ("Disabled");
$ ("#saveBtn"). CSS ("Color", "white");
}
}, "json");
}
}) ();