ajaxSubmit

前端之家收集整理的这篇文章主要介绍了ajaxSubmit前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
$("form").ajaxSubmit()介绍


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");

}@H_301_58@


@H_301_58@


@H_301_58@

经典例子@H_301_58@

http://blog.csdn.net/xuanjiewu/article/details/8212626
@H_301_58@

jquery 的ajaxSubmit 异步提交@H_301_58@

前台js@H_301_58@

$("#nickForm").ajaxSubmit({
type: "post",
url: "http://localhost:8080/test/myspace.do?method=updateNick&param=1",
dataType: "json",
success: function(result){
@H_301_58@

//返回提示信息
alert(result.nickMsg);
}
});
@H_301_58@

后台封装:@H_301_58@

public ActionForward toUpdateNickName(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){@H_301_58@

PrintWriter pw = response.getWriter();
JSONObject obj = new JSONObject();@H_301_58@

obj.put("nickMsg","昵称修改成功!");@H_301_58@

pw.print(obj);
pw.close();@H_301_58@

}@H_301_58@ 详细讲解

http://blog.csdn.net/h70614959/article/details/8810270
@H_301_58@

最近在使用ajaxForm,随便把使用方法记下下来,以便以后回顾。@H_301_58@

1 ,引入依赖脚本@H_301_58@

<script type="text/javascript" src="/js/jquery/jquery.form.js"></script> //ajaxForm 依赖脚本
@H_301_58@

<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>
@H_301_58@


@H_301_58@

2 使用方法@H_301_58@

<form name="testForm" id="testForm" >@H_301_58@

<input type="button" value="submit"/>@H_301_58@

</form>@H_301_58@

<script type="text/javascript">@H_301_58@

var ajax_option={@H_301_58@

url:"login",//默认是form action@H_301_58@

success:function(data){@H_301_58@

}@H_301_58@

$('#testForm').ajaxSubmit(ajax_option);@H_301_58@

</script>@H_301_58@

//注意$("#testForm") 引号中名称必须要和form元素id值要保持一致@H_301_58@

3 ajaxSubmit 和ajaxForm区别@H_301_58@

ajaxForm不能提交表单。在document的ready函数中,使用ajaxForm来为AJAX提交表单进行准备。提交动作必须由submit开始
@H_301_58@

ajaxSubmit马上由AJAX来提交表单。你可以在任何情况下进行该项提交。
@H_301_58@

4@H_301_58@

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 }; @H_301_58@

猜你在找的Ajax相关文章