javascript" name=code class="page_speeder_20720">整理版

$.ajax({

type:"POST",

url: //你的请求程序页面随便啦

async:false,//同步:当有返回值以后才会进行后面的js程序。

data://请求需要发送的处理数据

success:function(msg){

if (msg) {//根据返回值进行跳转

window.location.href = '你的跳转的目标地址';

}}ajax只接受最后返回的值,不会响应跳转请求更改浏览器地址栏地址转向的,你需要用js判断ajax的返回值是否要跳转,然后设置location.href实现跳转。ajax异步请求struts的action只会返回所请求页面的html源代码。

1、本页面跳转:"window.location.href"、"location.href"

2、上一层页面跳转:"parent.location.href"

3、最外层的页面跳转:"top.location.href"

举例说明:

如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写

"window.location.href"、"location.href":D页面跳转

"parent.location.href":C页面跳转

"top.location.href":A页面跳转

如果D页面中有form的话,

: form提交后D页面跳转: form提交后弹出新页面: form提交后C页面跳转 : form提交后A页面跳转

$(".deleteSection").click(function(){

let con = confirm("删除吗?")

let sid = $(this).siblings(".sectssSid").val()

if(con == true){

$.ajax({

type : "get",

url : "/regist_sys/deleteSection",

data : "sid=" + sid,

async : false,   //注意:此处是同步,不是异步

success : function(data){

if(data =="delete"){

window.location.href="/regist_sys/sectionInfo";//需要跳转的地址

}

}

});

}

})

传参

a.html页面传值:

$(“#btn”).click(function(){

window.location.href=’index.html?cont=’+count+’&name=’+name;

})

b.html页面接收值:

var url=window.location.href;  //获取当前页面的url

var len=url.length;   //获取url的长度值

var a=url.indexOf(“?”);   //获取第一次出现?的位置下标

var b=url.substr(a+1,len);   //截取问号之后的内容

var c=b.split(“&”);   //从指定的地方将字符串分割成字符串数组

var arr=new Array();  //新建一个数组

for(var i=0;i

var d=c[i].split("=")[1]; //从=处将字符串分割成字符串数组,并选择第2个元素

arr.push(d); //将获取的元素存入到数组中

}

传参

//传值:

url=xxx.aspx?id=1;

//接值:

string id=Request.Querystring["id"].ToString();

更多推荐

ajax 跳转 html页面传值,ajax实现页面跳转并传参