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>