The four snippet code example that implements the page jump function code through the JavaScript library jquery is as follows.
Example 1:
1234 |
$( function (){ var pn = $( "#gotopagenum" ).val(); //#gotopagenum是文本框的id属性 location.href = "NewList.aspx?pagenum=" +pn; //location.href实现客户端页面的跳转 }); |
Example 2:
Implementation jump: window.location = ' user!add.action?id=1 ';
If you need an AJAX non-flush asynchronous request:
1234567891011 |
www.169it.com$.ajax({
url:
‘user!add.action?id=1‘
,
type:
"POST"
,
cache :
false
,
dataType :
"json"
,
data : {activityId:activityId.val()},
success:
function
(data) {
alert(
"请求成功"
);
});
}
});
|
Example 3:
button Buttons fire jquery code when clicked (there is a condition to determine if the success of the jump page, if the condition is not enough to let him jump)
12345 |
if (条件 == true ){ document.location.href=目标url } else { alert( "条件为满足" ); } |
Example 4:
Jump through Ajax:
1234567 |
$.ajax( function (){ type: "POST" , dataType: "json" , url: "default.aspx" , //请求页面 data: "{id=1}" , complete: function (){location.href = "default.aspx" } //跳转页面 }) |
Implement page Jump function code
with JavaScript library jquery