jquery高版本的ajax调用

String data="";
        JSONObject jsonObj = new JSONObject();
        jsonObj.put("msg", ballotcount);
//        data="{msg:"+ballotcount+ "}";;
        PrintWriter out;
           try {
                response.setCharacterEncoding("UTF-8");
                out = response.getWriter();
                out.println(jsonObj.toString());
                out.close();
            } catch (IOException e) {
                log.error(e);
            }
        return null;

 

以上是jquery高版本调用的形式。

data="{msg:"+ballotcount+ "}";在jquery1.4以上版本就不能用了。需要改成:data="{/"msg/":"+ballotcount+ "}";

你可能感兴趣的:(jquery,Ajax,String,null)