有没有一种方法可以将类内的变量传递给php上的外部函数?

时间:2019-07-24 12:04:34

标签: php ajax wordpress

我正在编码一个小的“显示更多”按钮,该按钮使用ajax从服务器检索数组。它似乎与在函数内部声明和设置的普通响应一起工作,但是我无法从现有类内部的变量中检索数据。

import { Injectable } from '@angular/core';

    @Injectable({
        providedIn: 'root'
    })
    export class FacebookPixelService {
        constructor() { }
        load() {
            (function (f: any, b, e, v, n, t, s) {
                if (f.fbq) return; n = f.fbq = function () {
                    n.callMethod ?
                        n.callMethod.apply(n, arguments) : n.queue.push(arguments)
                }; if (!f._fbq) f._fbq = n;
                n.push = n; n.loaded = !0; n.version = '2.0'; n.queue = []; t = b.createElement(e); t.async = !0;
                t.src = v; s = b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s)
            })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
            (window as any).fbq.disablePushState = true; //not recommended, but can be done
            (window as any).fbq('init', '<your id>');
            (window as any).fbq('track', 'PageView');
        }
    }

我希望这会起作用,但在课堂上却没有。内部一切都按预期工作。我试图传递的数据是一个数组数组。每次必须插入一个元素时,我都会使用以下代码来做到这一点:

namespace Elementor;
class DB_Gallery extends \Elementor\Widget_Base {

    public $dbg_more = array();

    protected function render() {

        //Some code here

        $this->dbg_more[] = array(some data)
    }
}

function db_gallery_loadmore() {
    $db_gallery = new DB_Gallery;
    $response = $db_gallery->dbg_more;
}

0 个答案:

没有答案