ajaxUtil

var ajaxUtil = {
    /**
     * post请求
     * @param {Object} functionName 请求方法名
     * @param {Object} param    请求参数
     * @param {Object} respFuncCallBack 返回成功回调函数
     * @param {String} beforeMsg 请求前load信息
     * @param {Object} errcallback 返回失败回调函数
     * @param {Object} cworkState 网络不可用回调函数
     */
    ajaxByPost : function(functionName, param, respFuncCallBack,beforeMsg, errcallback,cworkState) {
        if (!checkworkState()) {
           
        <span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">console.log</span>('当前网络不可用,请重新设置',2000);
            if (null != cworkState) {
                cworkState();
            }
            
            return;
        }
        
        console.log("发送到java端加密之前的数据:" + param);
	var ld=null;
        console.log("请求的URL地址是:"+ website.path);
        $.ajax({
            //远程Rest接口
            url : website.path,
            type : "POST",
            cache : false,
            //返回的数据类型
            dataType : "json",
            data : {
                "message" : param
            },
            timeout : 60000,
            success : respFuncCallBack,
			beforeSend:function(){
				 if(!(undefined==beforeMsg||null==beforeMsg)){
				 	ld=$('<div>').loadingUI({content:beforeMsg})
				 }
			},complete:function(){
				 if(!(undefined==beforeMsg||null==beforeMsg||null==ld)){
				 	ld.remove();ld=null
				 }
			},
            error : function(jqXHR, textStatus, errorThrown) {
              console.log("错误信息======="+jqXHR.status+"===="+jqXHR.readyState+"===="+textStatus);
                //loadingUtil.hideLoading();
                // new Toast({
                    // context : $('body'),
                    // message : '服务器异常,返回数据失败'
                // }).show();
<pre name="code" class="javascript"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><span style="white-space:pre">			</span>console.log</span>('当前网络不可用,请重新设置',2000);
if (null != errcallback) { errcallback(jqXHR, textStatus, errorThrown); } } }); }, /** * get请求 * @param {Object} functionName 请求方法名 * @param {Object} param 请求参数 * @param {Object} respFuncCallBack 返回成功回调函数 */ ajaxByGet : function(url, param, respFuncCallBack,beforeMsg, errcallback,cworkState) { if (!checkworkState()) {
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><span style="white-space:pre">		</span>console.log</span>('当前网络不可用,请重新设置',2000);
if (null != cworkState) { cworkState(); } return; } var ld=null; $.ajax({ //远程Rest接口 url : url, type : "GET", cache : false, //返回的数据类型 dataType : "json", data : param, timeout : 60000, success : respFuncCallBack, beforeSend:function(){ if(!(undefined==beforeMsg||null==beforeMsg)){ ld=$('<div>').loadingUI({content:beforeMsg}) } },complete:function(){ if(!(undefined==beforeMsg||null==beforeMsg||null==ld)){ ld.remove();ld=null } }, error : function(jqXHR, textStatus, errorThrown) { console.log("错误信息======="+jqXHR.status+"===="+jqXHR.readyState+"===="+textStatus); console.log ('当前网络不可用,请重新设置',2000);
if (null != errcallback) { errcallback(jqXHR, textStatus, errorThrown); } } }); }};
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值