自己封装的一个juery ajax封装方法
/** * 发送消息方法 * url : /custom/mypassengerssave * josn :{"MyPassengersSaveRequest":"18888888888"}或者"key=a&vlaue=33" * * @param {string} url 适配器URL * @param {object}or{string} json Request参数 * @param {Object} response 回调函数名 * @param {Array} params_array 其他想要传给回调函数的值 ["12",id] * @param {string} type 是否要显示弹出框 1要,2不要 */function send(url, json, response,params_array,type) {var arguments_length = arguments.length; if(typeof type=="undefined"){ type = 1; } if(type==1){ /***var dialog = art.dialog({ lock: true, fixed:true, title:false, esc: false, //follow: document.getElementById('prj_title'), padding:0});***/ }$.ajax({type : "post",url : url,dataType : "json",data : json,beforeSend : function(XMLHttpRequest) {if(type==1){//dialog.visible();//$(".d-close").hide();}},complete : function(XMLHttpRequest, textStatus) {if(type==1){//dialog.close();}},success : function(data, textStatus) {if(null == data){alert(lang.errSys);return;}var jsonResponse = data;try {if(arguments_length>=4){params_array.unshift(jsonResponse);(response).apply(this, params_array);}else{(response).apply(this, [jsonResponse]);}} catch (e) {alert(lang.errCallBack+":"+e.description);}},error : function(xmlh, textStatus, errorThrown) {//try {//eval("var jsonResponse = " + xmlh.responseText + ";");//alert(lang.errSendMsg);//} catch (e) {//alert(lang.errJsonResponse + ":" + xmlh.responseText);alert(lang.errSendMsg);//return;//}}});}
?