Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使这个wordpress代理工作_Php_Wordpress - Fatal编程技术网

Php 如何使这个wordpress代理工作

Php 如何使这个wordpress代理工作,php,wordpress,Php,Wordpress,我正试图将此请求提交到我们的后端前端 前端部分如下所示: jQuery.ajax({ url: IC.ajaxurl, //http://localhost/wp-admin/admin-ajax.php type: "GET", data: { action: "get_search_suggestions", },

我正试图将此请求提交到我们的后端前端

前端部分如下所示:

  jQuery.ajax({
                url: IC.ajaxurl, //http://localhost/wp-admin/admin-ajax.php
                type: "GET",
                data: {
                    action: "get_search_suggestions",
                },
                success: function (data) {
                    console.log("data", data);
                },
                error: function (err) {
                    console.log("ERROR", err);
                }
            });
我不是wordpress开发人员,所以我尝试复制WP开发人员为代理所做的工作,这就是我得到的,但仍然不起作用:

add_action('wp_ajax_get_search_suggestions', function() {
    $api = new ArangoConnector();
    $data = stripslashes($_POST["data"]);
    send_json_response($api->getSuggestions($data));
});
getSuggestions()方法:

现在,当我从前端触发此呼叫时,我在google chrome的“网络”面板中发现以下错误:


请共享IC.ajaxurl代码请求URL:[…]wp admin[…]:看起来您正在尝试执行一项管理操作,但该操作不是管理操作或您未登录in@ShitalMarakana谢谢你的
http://localhost/wp-admin/admin-ajax.php
删除url:IC.ajaxurl尝试此url:
public function getSuggestions($data)
{
    $data = ($data);
    $json = json_decode($data);
    if (!$this->role_helper->isUserAllowedtoView($json->id))
        self::generateErrorResponse(self::PERMISSION_ERROR);

    $url = $this->getBaseUrl() . self::SEARCH_SUGGESTIONS . "/{$json->id}/";
    $response = wp_remote_get($url, self::getDefaultArgs());

    return self::generateResponse($response);
}