zoukankan      html  css  js  c++  java
  • jqeuery $.ajax 与后台jsone交互

    ============================action后台,我这里是SpringMVC================================================
    @Controller
    @RequestMapping("pfun")
    public class PubpowerfuncAction {
    @Autowired
    private PubpowerfuncServices pubpowerfuncServices;
     @RequestMapping("loadJb")
    public String qryJbInfo(HttpServletRequest request,HttpServletResponse response) throws IOException {

    List<Pubdll> list = pubpowerfuncServices.qrypubPowerfun();//查询数据
       //List转换成jsone类型

      Gson gson = new Gson();//需要导入 jar包我这里是gson-2.2.2.jar
      JsonReader reader = new JsonReader(new StringReader(list));
      String resultJson = gson.fromJson(reader, typeToken.getType());


    response.getWriter().write(resultJson);
    response.getWriter().close();
    return null;
    }
    }

    -======================================js===================
    //用的是jquery Ajax
    $.ajax({
    type : 'post',
    url : 'pfun/loadJb.hml?guid_dll='+ aguid,
    success:function(data){
    var dataObj=eval("("+data+")");
    for(var i=0;i<dataObj.length;i++){

    alert(dataObj[i].aguid);//获取后台的所有aguid

    }
    }
    });

  • 相关阅读:
    Feature fake , new view in comment.
    MeeGo Architect
    小米手机 怪诞行为经济学
    [转载]ten years as a programmer
    C++ 头文件
    关于AGILE/TDD 和传统的design
    你是否在开发正确的产品
    正确的创业
    MeeGo架构
    Unit Test
  • 原文地址:https://www.cnblogs.com/qgc88/p/3298495.html
Copyright © 2011-2022 走看看