$http().在传递带有“?”的额外Get参数时获取SyntaxError&”;
$http(). Get a SyntaxError when passing an extra GET parameter with "?"
我按照文档示例实现了一个fetch方法。只要我将?format=json
添加到$scope.url
,它就可以很好地工作。
$scope.method = 'GET';
$scope.url = "/activite/273/usagers?format=json";
$scope.fetch = function($event) {
$scope.code = null;
$scope.response = null;
$http({method: $scope.method, url: $scope.url, cache: $templateCache}).
success(function(data, status) {
$scope.status = status;
$scope.users = data;
$scope.search.status = $scope.userStatus;
$('#UserList').modal('show');
}).
error(function(data, status) {
$scope.response = data || "Request failed";
$scope.status = status;
$scope.userStatus = '';
});
$event.preventDefault();
};
知道吗?
根据API文档,看起来应该以任何方式在单独的params
对象中传递参数。因此:
$scope.method = 'GET';
$scope.url = "/activite/273/usagers";
$scope.params = {
format: 'json
};
事实上,由于json格式本身的原因,所有的"
都被"e;
替换了。我解决了这个问题。
相关文章:
- 将GET参数添加到q.io.xhr
- 使用history.js使用多个GET参数
- 应该 Backbone.js从 URL 中获取 GET 参数
- 根据 GET 参数选择选项
- $http().在传递带有“?”的额外Get参数时获取SyntaxError&”;
- 在带有标记的url上添加GET参数
- 如何在使用模式框的混合Form/HEF链接中添加其他GET参数
- 使用C++获取HTTP get参数
- AngularJS:转发到登录页面进行身份验证,保留路由作为GET参数
- 如何在Express中处理GET参数
- 如何将 GET 参数分配给 HTML 输入文本的值属性
- 基于 URL 中的 GET 参数嵌入模板
- history.pushState 我怎样才能摆脱 get 参数
- ASP.NET MVC:GET参数未正确反序列化
- 使用Django设置jquery pjax时出现问题(未设置头,但添加了GET参数)
- URL中包含GET参数的AJAX POST请求
- Regex-正则表达式模式在URL GET参数上失败
- 如何提取用于调用JS脚本的GET参数
- 使用AJAX请求和更改的GET参数重新加载整个页面
- Ajax可以阻止客户端看到GET参数吗