日期:2014-05-19 浏览次数:21039 次
(function($) {
$.fn.ajaxSubmitForm = function(options) {
var thisElement = $(this);
//当每次点击查询按钮时,查询的数据显示第一页
thisElement.find(":submit").bind("click",function(){
$("#queryPage").val("1");
});
var defaults = {
target : '#responseoutput',
type : 'post',//数据提交方式
dataType : 'html',//ajax返回数据格式
beforeSubmit : function(formData, jqForm, options){
return true;
},
success : function(responseText, statusText, xhr, $form){
$("#" + options.showPagerId).html("");
$("#" + options.showPagerId).append(responseText);
},
resetForm : false,
timeout : 10000,
error:function(tip){
alert("出错了:" + tip.status);
},
showPagerId:'showPager'
};
var options = $.extend(defaults, options);
this.each( function() {
var output = document.getElementById("responseoutput");
if (output == null) {
var putdiv = document.createElement("div");
putdiv.id = "responseoutput";
putdiv.style.display = "none";
document.body.appendChild(putdiv);
}
$(thisElement).ajaxForm(options);
$(thisElement).trigger("submit");
});
};
})(jQuery);