我有是一个链接的点击是如下如何在JavaScript中更改window.location.href,然后执行更多的JS?
cj_redirecturl="/HomeWork/main/load_course";
utility.xhttprw.data(cj_redirecturl,{data:courseid},function(response){
if(response){
window.location.href=base_url+"main";
///next
utility.xhttprw.data(redirecturl,{data:""},function(response){
if(response){
id=ent;
document.getElementById('content').innerHTML=response;
// Assignemnt module
//Call function from javascript/assignment.js file to display particular assignment (ent:means assignment_id) //
if(con==5)
{
get_assignment_id(ent);
}
if(con==9)
{
get_content_details(ent);
}
} //end of response
},false,false,false,'POST','html',true);
}
},false,false,false,'POST','html');
在上面的代码window.location.href=base_url+"main";
页面重定向到其相应的页面,但这种停止写只是旁边的代码的执行执行的代码snippent。现在我希望这个代码在写入时被执行,即首先代码应该带我到相应的“主”页面,然后编写代码,之后必须执行并提供所需的输出。
有人可以指导我做到这一点吗?
这不会这样工作,当你重定向你得到另一个页面加载,这意味着你松散你的JavaScript内存中的一切。添加一个参数到重定向,通过它你知道你什么时候重定向,并在页面加载hanle它 – Rumplin
怎么可以做 –
因为你标记jquery我不知道哪个代码是jQuery在这里 – Rumplin