zoukankan      html  css  js  c++  java
  • Jqueryd的一些 总结

    JSP层

       /*
    发送data 主要有三种方式:
    1、json 数组(推荐1)
    2、url拼接
    3、表单的序列化 serialize
    */

    <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript">
    $(function(){
    $("img").click(function(){
    $("input").css("border","3px dotted red");

    $.ajax({
    url:'B',  //链接的servlet名字
    //data:{userName:$('input').val()}, //传输的数据
    data:$("input").serialize(),  //表单序列化传输数据
    dataType:'text',  //传输的类型
    type:'GET',  //传输方式
    success:function(result){
    alert(result);  //传输成功后 弹个窗
    },
    error:function(){
    alert("发生错误...");  //失败了弹个窗
    },
    timeout:2000   //设定一个限时标准(超过就报错)
    });
    });
    });
    </script>
    </head>
    <body>
    <form id="frm1">
    <input type="text" name="userName" value="text文本框" >
    <img src="5.jpg">
    </form>
    </body>

     

     

     

    Servlet层

     

     

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("访问doGet");
    String userName = request.getParameter("userName");
    PrintWriter out = response.getWriter();
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    out.println("输出数据:"+ userName);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doGet(request, response);
    System.out.println("访问doPost");
    PrintWriter out = response.getWriter();
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    out.println("在doPost输出数据:");

    }

    }

     

     

     

     

  • 相关阅读:
    hbase coprocessor 二级索引
    文档:ubuntu安装.pdf
    Python过滤敏感词汇
    nginx 对django项目的部署
    ZooKeeper 的常用操作方法
    Python操作reids
    教你为nginx 配置ssl 证书!
    单线程多任务异步爬虫
    go语言入门之环境的搭建
    关于csrf跨站请求伪造攻击原理,与csrftoken防范原理
  • 原文地址:https://www.cnblogs.com/LWMLWM/p/7233885.html
Copyright © 2011-2022 走看看