zoukankan      html  css  js  c++  java
  • 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); } } }); }};
    
    
  • 相关阅读:
    Android开发-API指南-<uses-configuration>
    Android开发-API指南-<supports-screens>
    Android开发-API指南-<supports-gl-texture>
    Android开发-API指南-<service>
    Android开发-API指南-<receiver>
    Android开发-API指南-<provider>
    Android开发-API指南-<permission-tree>
    maven scope 以及依赖传递
    转发和重定向
    Apache
  • 原文地址:https://www.cnblogs.com/mcdnf/p/5158293.html
Copyright © 2011-2022 走看看