如何使用openCPU JavaScript API或jQuery向openCPU(作为本地服务器运行)库添加自定义(以字符串形式)R函数?
使用类似
的内容var myfunc = "ff <- function(x,y) { x+y }";
$.post("http://localhost:8483/R/call/base/identity/save",
{x : myfunc},
function(res) {...});
在浏览器中产生以下错误
Cross-Origin Request Blocked: The Same Origin Policy disallows
reading the remote resource at http://localhost:8483/R/call
/base/identity/save. (Reason: CORS header 'Access-Control-Allow-
Origin' missing)
答案 0 :(得分:0)
您应该在ajax帖子设置中使用crossDomain:true
$.post("http://localhost:8483/R/call/base/identity/save",
crossDomain: true,
{x : myfunc},
function(res) {...});