domatskiy/bitrix-ajax-response

v1.4.0 2017-10-29 08:04 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:29:03 UTC


README

安装

composer require domatskiy/bitrix-ajax-response

使用 Closure

    new AjaxResponse(function(){
        
        ... 
        
        });

使用类方法

    new AjaxResponse('class@method');

使用旧版 bitrix api

重要:在请求中需要传递字段 'ajax',其值为 'Y'

    new AjaxResponse('class@method', true);

示例

define("STOP_STATISTICS", true);
define('NO_AGENT_CHECK', true);
define("STATISTIC_SKIP_ACTIVITY_CHECK", true);
 
use Domatskiy\AjaxResponse;
 
# подключаем bitrix
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
 
if(class_exists('\Domatskiy\AjaxResponse')){
 
    new AjaxResponse(function(){
     
        $result = new AjaxResponse\Result();
        $data = array();
         
        # body
         
        $result->setData($data);
        return $result;
         
        });
    
    }