zoukankan      html  css  js  c++  java
  • Ajax简单示例

    JSP:

    <!-- 搜索框 -->
    <div class="col-xs-6 pull-right">
    <div class="input-group">
    <label for="beginTime" style="margin-right:15px">DeviceIP</label> <input type="text"
    class="form-control" id="deviceIp" name="deviceIp" placeholder="please input DeviceIP">
    <label for="owner" style="margin-right:15px"> DeviceAlias</label>
    <input type="text" class="form-control" id="deciceName" placeholder="please input DeviceAlias">
    <span class="input-group-btn">
    <button id="go" class="btn btn-default search" type="button">Go!</button>
    </span>
    </div>
    </div>

    JS:

    $(function(){
    $("#go").click(function(){
    var deviceIp = $("#deviceIp").val();
    var deviceAlias = $("#deciceName").val();
    $.ajax({
    url:"${pageContext.request.contextPath}/device/searchList",
    type:'post',
    dataType: "json",
    data:{
    "deviceIp":deviceIp,
    "deviceAlias":deviceAlias
    },
    success: function(data){
    alert(success);
    $.each(data,function(index,element){
    alert(element.deviceIp);
    alert(element.deviceAlias);
    })
    },
    error:function(){
    alert(error);
    }

    });

    });
    });

    Controller:

    @RequestMapping(value = "/searchList",method = RequestMethod.POST)
    private String searchList(Model model,HttpServletRequest request,
    HttpServletResponse response) throws Exception
    {
    response.setCharacterEncoding("UTF-8");
    String searchIp = request.getParameter("deviceIp");
    String searchAlias = request.getParameter("deviceAlias");

    System.out.println(searchIp+" : "+searchAlias);
    return "searchList";
    }

  • 相关阅读:
    数仓1.3 |行为数据| 业务数据需求
    数仓1.1 |概述| 集群环境搭建
    麒麟Kylin
    ng--todolist
    mysql必知必会--用正则表达式 进行搜索
    mysql必知必会--用通配符进行过滤
    mysql必知必会--数 据 过 滤
    mysql必知必会--过 滤 数 据
    mysql必知必会--排序检索数据
    mysql必知必会--检 索 数 据
  • 原文地址:https://www.cnblogs.com/rexienk/p/9044373.html
Copyright © 2011-2022 走看看