【问题标题】:Import custom function to openCPU导入自定义函数到openCPU
【发布时间】:2015-10-29 16:42:36
【问题描述】:

如何使用 openCPU JavaScript API 或 jQuery 将自定义(以字符串形式)R 函数添加到 openCPU(作为本地服务器运行)库?

使用类似的东西

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)

【问题讨论】:

    标签: javascript jquery r opencpu


    【解决方案1】:

    你应该在你的 ajax 帖子设置中使用 crossDomain: true

    $.post("http://localhost:8483/R/call/base/identity/save",
           crossDomain: true,
           {x : myfunc},
           function(res) {...});

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-14
      • 2015-10-04
      相关资源
      最近更新 更多