http://www.cnblogs.com/qiantuwuliang/archive/2009/09/14/1566604.html
jQuery.extend 函数详解
http://www.cnblogs.com/RascallySnake/archive/2010/05/07/1729563.html
http://localhost:9527/shop/admin/tag!ggg.do?ajax=yes
cms返回json串
只要将action中的方法返回值写成
this.json="{result:111}";
return this.JSON_MESSAGE;
就可以了
hotword例子
public String listAllTag(){
List<Tag> taglist =tagManager.list();
String tagJson = JSONArray.fromObject(taglist).toString();
this.json = tagJson;
return this.JSON_MESSAGE;
}
public void ggg() throws IOException{
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=GBK");//解决中文乱码
PrintStream out = new PrintStream(response.getOutputStream());//获取out输出对象
out.println("111111");
}
经典例子
http://blog.csdn.net/xuanjiewu/article/details/8212626
jquery 的ajaxSubmit 异步提交
前台js
$("#nickForm").ajaxSubmit({
type: "post",
url: "http://localhost:8080/test/myspace.do?method=updateNick¶m=1",
dataType: "json",
success: function(result){
//返回提示信息
alert(result.nickMsg);
}
});
后台封装:
public ActionForward toUpdateNickName(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
PrintWriter pw = response.getWriter();
JSONObject obj = new JSONObject();
obj.put("nickMsg","昵称修改成功!");
pw.print(obj);
pw.close();
}
详细讲解http://blog.csdn.net/h70614959/article/details/8810270
最近在使用ajaxForm,随便把使用方法记下下来,以便以后回顾。
1 ,引入依赖脚本
<script type="text/javascript" src="/js/jquery/jquery.form.js"></script> //ajaxForm 依赖脚本
<script type="text/javascript" src="/js/jquery/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="/js/jquery/jquery.easyui.min.js"></script>
2 使用方法
<form name="testForm" id="testForm" >
<input type="button" value="submit"/>
</form>
<script type="text/javascript">
var ajax_option={
url:"login",//默认是form action
success:function(data){
}
$('#testForm').ajaxSubmit(ajax_option);
</script>
//注意$("#testForm") 引号中名称必须要和form元素id值要保持一致
3 ajaxSubmit 和ajaxForm区别
ajaxForm不能提交表单。在document的ready函数中,使用ajaxForm来为AJAX提交表单进行准备。提交动作必须由submit开始
ajaxSubmit马上由AJAX来提交表单。你可以在任何情况下进行该项提交。
4
option的参数 var options = { target: '#output1',// target element(s) to be updated with server response beforeSubmit: showRequest,// pre-submit callback success: showResponse // post-submit callback // other available options: //url: url // override for form's 'action' attribute //type: type // 'get' or 'post',override for form's 'method' attribute //dataType: null // 'xml','script',or 'json' (expected server response type) //clearForm: true // clear all form fields after successful submit //resetForm: true // reset the form after successful submit // $.ajax options can be used here too,for example: //timeout: 3000 };