使用带有AngularJS的DocRaptor web服务
Using DocRaptor web service with AngularJS?
我正在尝试使用DocRaptor从AngularJS应用程序生成Excel(.xls)文件。在尝试DocRaptor的getting Started文档中描述的简单POST请求时,我不断收到以下错误。他们的文件声称他们支持CORS请求。任何帮助都将不胜感激。
Chrome中的错误消息:
OPTIONS https://docraptor.com/docs?user_credentials=my-api-key
XMLHttpRequest cannot load https://docraptor.com/docs user_credentials=my-api-key.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. The response had HTTP status code 404.
以下是我的AngularJS控制器中的JavaScript代码:
var forDocRaptor = {
"doc" : {
"test": true,
"document_type": "pdf",
//Just trying simple pdf for now
"name": "adoc.pdf",
"document_content": '<div>PDF generation test</div>',
"strict": "none",
"javascript": true,
"tag": "tag",
"async": false
}
}
$scope.exportToExcel = function() {
$http.post('https://docraptor.com/docs?user_credentials=my-api-key', forDocRaptor)
.success(function(res) {
console.log(res)
});
}
我也遇到了同样的问题。你应该发送-
data:forDocRaptor
此外,出于某种原因,如果您使用
method:'POST'
它有效,但$http.post不能
所以,你的代码看起来是这样的:
$http({
method:'POST',
url: URL,
data:forDocRaptor
}).success(function(res){
console.log(res)
})
相关文章:
- Javascript:selenium Web驱动程序isDisplayed()不工作
- 在Web应用程序中使用Highcharts javascript
- WebDriverException:tinyMCE未在selenium Web driver java中定义
- Selenium Web驱动程序和javascript
- Windows形成web浏览器控件和Javascript更改的DOM
- 如何将javascript事件从web浏览器wpf控件发送到wpf的c#代码
- Steam Web API:I'我不知道该如何处理这个看起来像哈希的url来生成图像
- 在调用speak之前预加载Web Speech API
- 如何在visualstudio中调试web api时编辑javascript文件
- 是否存在React Native“;WEB代码安全防护”;
- 如何在Ionic Android中将Javascript注入到web视图中
- 将复杂对象从angular js传递到web api,它总是返回404
- 基于api密钥的NodeJS web服务
- 将下载链接从web浏览器传递给第三方应用程序
- 基于Web的JS调试库
- 使用javascript在客户端上使用Web服务
- 如何通过安全的https连接在javascript中使用基于soap xml的Web服务
- 从Javascript连接到SOAP Web服务
- 自定义HTML元素属性未显示-Web组件
- 使用带有AngularJS的DocRaptor web服务