本文介绍了无法通过JavaScript调用我的Machine Learning Studio Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的ML实验(虹膜分类),并从该实验成功生成了Web服务.但是,当我从创建的简单HTML页面(使用Javascript)调用此Web服务时,始终收到以下错误...

I created a simple ML experiment (Iris classification) and successfully generated web services from this experiment.  However when I go to call this web service from a simple HTML page that I created (using Javascript) I keep getting the following error...

已被CORS策略阻止:请求的资源上不存在"Access-Control-Allow-Origin"标头.如果不透明的响应满足您的需求,请将请求的模式设置为"no-cors",以在禁用CORS的情况下获取资源.

从我读到的内容来看,这可能意味着我需要在服务器上配置CORS才能接受来自其他域的请求,但是对于我来说,我不知道该在哪里进行此操作.

From what I've read this could mean that I need to configure CORS on the server to accept requests from other domains, but for the life of me I can't figure out where to do this.

任何建议将不胜感激.

推荐答案

一种解决方案是,当您在原始代码中定义源代码时,可以定义crossOrigin:null

A solution is when you define your source in your original code, you can define crossOrigin : null 

而且,您也可以尝试通过将本地文件上传到网络来托管本地文件.

And also, you can try to Host your local file by uploading it to the web.

此致

雨桐


这篇关于无法通过JavaScript调用我的Machine Learning Studio Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 18:59