I have a requirement which needs to load after reloading the page with Jquery. Below is the code.
$("a[id='gobutton']").click(function(e)) {
location.reload();
somefunc();
});
function somefunc() {
alert("run my script"); }
I have a requirement which needs to load after reloading the page with Jquery. Below is the code.
$("a[id='gobutton']").click(function(e)) {
location.reload();
somefunc();
});
function somefunc() {
alert("run my script"); }
After you run location.reload() your code is gone. You cant run anything after it. You would need to pass an argument to the page to run the function.
let param = new URLSearchParams(location.search);
$("a[id='gobutton']").click(function(e)) {
location.href = '?somefunc=true'
});
if(param.get('somefunc'){
somefunc()
}
function somefunc(){}