zoukankan      html  css  js  c++  java
  • JQuery ajax 返回值如何进行赋值

    问题如下
    ajax提交请求获得的数据我把它附给一个var变量,但老是报一个错误,没有对象

    网上资料:
    这个$.ajax可以有返回值的,返回值是xmlhttprequest对象
    是为了能够让返回值正确赋值,你必须把ajax设置为同步的,而非异步的。
    async :false

     

    js代码:

    var old = "";
    $.ajax({       
    type:"POST",
    url:"http://127.0.0.1:8080/PeugeotRace/MgmtLoginServlet.do?action=query",
    data:"id="+newsids[i].value,
    //防止自动转换数据格式。
         async :false,
    success:function(msg){ 
    old = msg;
    }    
    });
    


     

    java代码:

    if ("query".equals(action)) {
    String id = request.getParameter("id");
    if (UtilTool.isNotBlank(id)) {
    INoticeService noticev = new RgNoticeServiceImpl(); 
    try {
    RgNotice notice =noticev.getoneRecord(id);
    if(notice!=null){
    PrintWriter out = response.getWriter();
    //输出数据
    out.println("添加日期:"+notice.getVotetime().toString().substring(0, 11)+"<br>内容:"+notice.getContent());
    out.flush();
    out.close();
    } 
    } catch (Exception e) {
    e.printStackTrace();
    } 
    }
    }


     

  • 相关阅读:
    ps太卡
    vba 数字变为excel对应列的字母
    爬去网页离线数据
    vba 得到数字
    Sql Server generate table structure document
    Git
    windows凭据管理器
    修改注册表
    Software List
    1009 说反话
  • 原文地址:https://www.cnblogs.com/dqsweet/p/4927811.html
Copyright © 2011-2022 走看看