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");
}
經典例子
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????
?? }; ??
總結
以上是生活随笔為你收集整理的ajaxSubmit的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python sqlite数据库_用Py
- 下一篇: 笔记:Zygote和SystemServ