var pm = pm || {};
pm.data = pm.data || {};// 用于存放临时的数据或者对象
/**
* 将form表单元素的值序列化成对象
*
* @example pm.serializeObject($('#formId'))
*
* @requires jQuery
*
* @returns object
*/
pm.serializeObject = function(form) {
var o = {};
$.each(form.serializeArray(), function(index) {
if (this['value'] != undefined && this['value'].length > 0) {// 如果表单项的值非空,才进行序列化操作
if (o[this['name']]) {
o[this['name']] = o[this['name']] + "," + this['value'];
} else {
o[this['name']] = this['value'];
}
}
});
return o;
};
/**
* 改变jQuery的AJAX默认属性和方法
*
* @requires jQuery
*
*/
$.ajaxSetup({
type : 'POST',
error : function(XMLHttpRequest, textStatus, errorThrown) {
try {
parent.$.messager.progress('close');
parent.$.messager.alert('错误', XMLHttpRequest.responseText);
} catch (e) {
alert(XMLHttpRequest.responseText);
}
},
dataType:'json',
traditional:true
});