[英]angular ajax: Unexpected token I in JSON at position 0
I'm trying to sent html
as json
in http post request
. 我正在尝试在
http post request
发送html
作为json
。 But when I'm trying to make $http.post
request, I've got the following error: 但是,当我尝试生成
$http.post
请求时,我遇到以下错误:
angular.js:12783 SyntaxError: Unexpected token I in JSON at position 0
at Object.parse (native)
at fromJson (http://localhost:9001/bower_components/angular/angular.js:1274:14)
at defaultHttpResponseTransform (http://localhost:9001/bower_components/angular/angular.js:9703:16)
at http://localhost:9001/bower_components/angular/angular.js:9794:12
at forEach (http://localhost:9001/bower_components/angular/angular.js:341:20)
at transformData (http://localhost:9001/bower_components/angular/angular.js:9793:3)
at transformResponse (http://localhost:9001/bower_components/angular/angular.js:10582:21)
at processQueue (http://localhost:9001/bower_components/angular/angular.js:15097:28)
at http://localhost:9001/bower_components/angular/angular.js:15113:27
at Scope.$eval (http://localhost:9001/bower_components/angular/angular.js:16359:28)
My code (angular) is given below: 我的代码(角度)如下:
$scope.generate_pdf = function() {
var html = angular.element('html').html(); // get all html
var service = API.getService();
// JSON.stringify( { html: html } this also cause same error
service.downloadPdf({}, { html: html },
function(res) {
console.log("res : ", res);
}, function(err) {
console.log("err : ", err);
});
};
How can I solve this problem? 我怎么解决这个问题? Thanks in Advance
提前致谢
SyntaxError: Unexpected token I in JSON at position 0
意味着服务器响应无效JSON,打开控制台中的网络选项卡并检查请求的响应以查看错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.