我想在重定向页面后调用一个函数。
在我的函数中,我放置了一个 ID 参数,但是当我检查控制台时,它不会显示。我知道我可以通过单击事件运行它,但我不会从上一页获取 ID 参数。
有办法完成吗?
代码:
function encode(item_id){
$('.js-encode').click(function(){
var url = $(this).data('url');
location.href = url; // new url
save(item_id); // call function after new url finish loading
});
}
function save(item_id){
console.log(item_id); // check if there's item_id exists
}
Run Code Online (Sandbox Code Playgroud)