摘要: 服务器端拼接json格式的字符串:String string = "{\"name\":"+@parm+",\"sex\":"+@sex+"}";\\键值对除了数值型都要加引号response.getWriter.writer(string);//[echo $string;]浏览器端接收参数:1:var obj = eval("("+data+")")//方式一不安全2:在$ajax()方法中指明dataType:"json" 在回调 阅读全文
posted @ 2013-01-30 14:29 roscee 阅读(155) 评论(0) 推荐(0) 编辑
摘要: function ajax(){$.get( "url", {"name":"zhangsan","sex":"man"}//json 格式传送参数 function(result){//result(可重命名) 为返回结果 $("#id").html(result); })}get和post的区别在于参数的长度、和浏览器的缓存function ajax(){$.ajax({ type:"get/post", url:"url", da 阅读全文
posted @ 2013-01-30 13:27 roscee 阅读(251) 评论(0) 推荐(0) 编辑
摘要: JavaScript 中:function ajax(){var xmlHttpRequerst;try{ xmlHttpRequest = new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari}catch(e){xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");// code for IE6, IE5}//执行xmlHttpRequest.onreadystatechange(function(){if(xmlHttpReq 阅读全文
posted @ 2013-01-30 11:20 roscee 阅读(167) 评论(0) 推荐(0) 编辑