jQuery中ajax和post处理json的不同
来源:互联网 发布:七天网络注册 编辑:程序博客网 时间:2024/06/10 06:58
近日在做门户的用户评论时,好长时间没有用jquery了正好用一下,没想到偷工用了post方法去处理ajax回调的json数据,死活取不到,后台就是有json返回了。不料这么小小一个问题挂了我好几个小时,后来我ajax方法处理,居然OK,一比较发现原来post方法回调json必须eval一下,而ajax方法做了默认处理了。 望各位小心。。。
function haha() {jQuery.post("addComment!comment.action", function aa(data) { data = eval(data);//POST方法必加,ajax方法自动处理了 alert(data[0].userId); alert(data[0].userName);},"json");jQuery.ajax({type:"post",url:"addComment!comment.action",dataType:"json",success: function aa(data) { alert(data[0].userId); alert(data[0].userName);}});}
后台:
public String comment() {try{User u = new User("user", "koko");list = new ArrayList<User>();list.add(u);//map.put("id", userId);//JSONObject jb = JSONObject.fromObject(list); // name:"+userName +",//info = jb.toString();System.out.println(list);}catch (Exception e) {e.printStackTrace();}return SUCCESS;}
配置:
<package name="ajax" extends="json-default"><action name="addComment" class="org.test.action.CommentAction"><result type="json"> <param name="root">list</param></result></action>。。。。。。
- jQuery中ajax和post处理json的不同
- jQuery中ajax和post处理json的不同
- jquery AJAX中get与POST方式的不同
- jquery AJAX中get与POST方式的不同
- JQuery中ajax和JSON的获取
- jquery的ajax和post
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- 理解jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法
- JQuery中$.get、$.post、$.getJSON和$.ajax的用法
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法详解
- Oracle DB Link .
- getchar与getch的区别
- android 实现发送彩信方法 (MMS),非调用系统界面
- Pyhton——List,Sorting,Tuples类型
- JAVA反编译工具JAD
- jQuery中ajax和post处理json的不同
- android-代码设置editText最大长度
- 【Floyd算法】hdu 2868
- Oracle 帐号基本管理
- BUILD_BUG_ON
- 又一个起点
- TableCellRender小例子
- Oracle 常用的V$ 视图脚本 .
- 《UNIX环境高级编程》第11章线程【读书笔记】