weixin_33743248 2018-09-23 17:09 采纳率: 0%
浏览 42

通过Rstudio将Ajax转换为R

I started the server in Rstudio using servr::httd().

I hope to learn how to post data to R and back and I found the below. (jQuery jsonrpc 2.0 call via .ajax() gets correct response but does not work?)

I implemented the below codes on index.html and it looked fine.

However, I am unsure what I should code to implement the server side in Rstudio.

The server codes from above URL is for python, and I have been reading for a few days without finding the way how Rstudio should be done. Please help.

<html>
<head>
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>

   <script>
      $(document).ready(function(){

         $.ajax({
            url: 'http://localhost:4321/', 

            data: JSON.stringify ({jsonrpc:'2.0',method:'add', params:[1400,2100],id:"jsonrpc"} ),  

            type:"POST",

            dataType:"json",
            success:  function (data)       { alert("The result is : " + data.result);},
            error: function (err)  { alert ("Error");}

         });

      });


  </script>


</head>
<body>
  <h1> jQuery JSON RPC 2.0 demo </h1>

</body>
</html>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料