Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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
Javascript AngularJS Wordpress JSON API插件返回html而不是JSON_Javascript_Angularjs_Wordpress_Http Get_Wordpress Json Api - Fatal编程技术网

Javascript AngularJS Wordpress JSON API插件返回html而不是JSON

Javascript AngularJS Wordpress JSON API插件返回html而不是JSON,javascript,angularjs,wordpress,http-get,wordpress-json-api,Javascript,Angularjs,Wordpress,Http Get,Wordpress Json Api,我试图从我的wordpress博客上获取最近的帖子,但它返回的是html而不是json。我想使用json使访问博客内容更容易。我已经安装并激活了插件。以下是我为获得帖子所做的: $http.get('blog/?json=get_recent_posts') .success(function(data, status, headers, config){ $scope.post = data; console.log(data); }) .error(f

我试图从我的wordpress博客上获取最近的帖子,但它返回的是html而不是json。我想使用json使访问博客内容更容易。我已经安装并激活了插件。以下是我为获得帖子所做的:

  $http.get('blog/?json=get_recent_posts')
  .success(function(data, status, headers, config){
      $scope.post = data;
      console.log(data);
  })
  .error(function(data, status, headers, config){-
      console.log("unable to access!!!!!!!!!!!");
  });

它返回html而不是json的原因是什么?有什么解决办法吗?其他一些帖子提到使用jsonp,但这对我也不起作用。

我可能做错了,但当我在
http://www.example.com/
像这样:

http://www.example.com/index.php?rest_route=/my/rest/route/here

我最终得到了正确的回应

我花了很长时间才弄明白这一点,最后摸索出了一个返回给我的HTML格式的URL。我希望以
http://www.example.com/wp_json/wp/v2/my/rest/route/here
,但我只收到了HTML响应