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

}



经典例子

http://blog.youkuaiyun.com/xuanjiewu/article/details/8212626

jquery 的ajaxSubmit 异步提交

前台js

$("#nickForm").ajaxSubmit({
     type: "post",
     url: "http://localhost:8080/test/myspace.do?method=updateNick&param=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.youkuaiyun.com/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    
   };   


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值