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";
    }

  • 相关阅读:
    IDEA开发常用快捷键
    常见操作系统的分类
    预科班第四次考核总结
    博客园使用office 365写博客
    大三上学期十二周总结
    python循环和布尔表达式总结
    灵活运用绑定变量---declare匿名块使用绑定变量
    Oracle 10G强大的SQL优化工具:SQL Tuning Advisor
    40个DBA日常维护的SQL脚本--1113
    awr相关指标解析
  • 原文地址:https://www.cnblogs.com/rexienk/p/9044373.html
Copyright © 2011-2022 走看看