jQuery的post()和serialize()方法。

jQuery的serialize()方法的作用。

jQuery官网的API:http://api.jquery.com/

或参照该例子的中文API:http://jquery.cuishifeng.cn/jQuery.post.html

例子:

$("#save").click(function(){
if (checkType()) {
$.post("?pageAction=save", $("#insertForm").serialize(), function(re){
if(re==null){
alert('保存成功!');
window.parent.location.reload(true);
}else{
alert(re);
}
 },"json");
}
});


官网解释:

.serialize()

Encode a set of form elements as a string for submission.

编码一组表单元素作为提交字符串。

jQuery.post( url [, data ] [, success ] [, dataType ] )

  • url
    Type:  String
    A string containing the URL to which the request is sent.
  • data
    Type:  PlainObject or  String
    A plain object or string that is sent to the server with the request.
  • success
    Type:  FunctionPlainObject data,  String textStatus,  jqXHR jqXHR )
    A callback function that is executed if the request succeeds. Required if  dataType is provided, but can be  null in that case.
  • dataType
    Type:  String
    The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值