0

How to add custom (in the form of a string) R function to openCPU (running as a local server) library using openCPU JavaScript API or jQuery?

Using something like

var myfunc = "ff <- function(x,y) { x+y }";
$.post("http://localhost:8483/R/call/base/identity/save",
       {x : myfunc},
       function(res) {...});

yields the following error in the browser

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)
zx8754
  • 52,746
  • 12
  • 114
  • 209
yari
  • 165
  • 1
  • 6

1 Answers1

0

You should use crossDomain: true in your ajax post settings

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