ajax.tool.js 1.2 KB
var ajaxTool = {
	/**
	 * ajax 请求
	 * 
	 * @param options
	 * @param callback
	 */
	ajaxRequest : function(options, callback) {
		var conf = {
			type : "POST",
			url : options.url,
			dataType : "json",
			async : false,
			data : {},
			success : function(rs) {
				try {
					if (callback) {
						callback.apply(this, [ rs ]);
					}
				} finally {
				}
			},
			error : function() {
			}
		};
		$.extend(conf, options);
		$.ajax(conf);
	},

	ajaxPost : function(url,frm, callback) {
		$.post(url, $(frm).serialize(),callback);
	},
	sendAjax : function(URL, Parm, SuccFun, ErrorFun, PostTYPe, dataType, cacheType, asyncType) {
		PostTYPe = (PostTYPe == null) ? "GET" : "POST";
		cacheType = (cacheType == null) ? false : true;
		dataType = (dataType == null) ? "json" : dataType;
		ErrorFun = (ErrorFun == null) ? ajaxTool.ajaxError : ErrorFun;
		asyncType = (asyncType == null) ? true : false;
		$.ajax({
			url : URL,
			data : Parm,
			cache : cacheType,
			type : PostTYPe,
			dataType : dataType,
			success : SuccFun,
			async : asyncType,
			error : ErrorFun,
			complete : function(XMLHttpRequest, textStatus) {
				var s = XMLHttpRequest.status;
				if (s == 202) {
					// isp.relogin();
				}
			}
		});
	}

};