zoukankan      html  css  js  c++  java
  • 通过javascript库JQuery实现页面跳转功能代码

    通过javascript库JQuery实现页面跳转功能代码的四段代码实例如下。

    实例1:

    1
    2
    3
    4
    $(function(){
    var pn = $("#gotopagenum").val();//#gotopagenum是文本框的id属性
    location.href = "NewList.aspx?pagenum="+pn;//location.href实现客户端页面的跳转
    });

    实例2:

    实现跳转:window.location = 'user!add.action?id=1';

    如果需要ajax无刷新的异步请求:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    $.ajax({
       url:'user!add.action?id=1',
       type:"POST",
       cache : false,
       dataType : "json",
       data : {activityId:activityId.val()},
       success:function(data) {
            alert("请求成功");
        });
       }
      });

    实例3:

    button按钮在单击时激发jquery代码(里面有条件判断如果成功就让跳转页面,如果条件不满足就不让他跳转)

    1
    2
    3
    4
    5
    if(条件 == true){
     document.location.href=目标url
    }else{
     alert("条件为满足");
    }

    实例4:

    通过ajax实现跳转:

    1
    2
    3
    4
    5
    6
    7
    $.ajax(function(){
    type:"POST",
    dataType:"json",
    url:"index.php",//请求页面
    data:"{id=1}",
    complete:function(){location.href ="http://www.169it.com"}//跳转页面
    })
  • 相关阅读:
    【Mysql学习笔记】浅析mysql的binlog
    HBase 学习笔记---守护进程及内存调优
    字符集例子-同一字符不同字符集编码不同及导入导出的乱码
    随机访问
    格式化的代价
    读写文本文件
    缓冲
    加速I/O的基本规则
    序列化再探讨
    数据库I/O:CMP、Hibernate
  • 原文地址:https://www.cnblogs.com/besty/p/3913693.html
Copyright © 2011-2022 走看看