Shiny - save javascript variable to mysql database

I work with a brilliant server.
My application has an entry in the search box. Based on this input, the output is a dataTable that has click links .
My ui.r application contains a JavaScript function that sets the value of a variable whenever a link is clicked. Let the variable be pressed Link . Now I want to save this link value to mysql or any other database. How to do it?

I tried ajax, php unnecessarily. What I did is described in this question: saving json data in a json file using ajax PHP , but I think php files do not work with brilliant ones. Please, help.

EDIT 1

added ui.R code

tags$script(HTML(" function clickFunction(clickedLink){ //alert(clickedLink); var cl = clickedLink; Shiny.onInputChange('clickedLink',cl); } ")) 

added code to .R server

 observe({ print(input$clickedLink) }) 

EDIT 2
For information only, links are of the form

 <a onclick="clickFunction(this.href); " target="_blank" href="http://SOMETING.com">SOMETHING</a> 
+1
javascript jquery mysql r shiny
source share
1 answer

I assume that you know how to save the variable as soon as you get it in R. If not, use the RMySQL package and read their tutorial - https://github.com/rstats-db/RMySQL

So your main problem is to get the javascript variable in R. You can use Shiny.onInputChange for this. There is a small simple tutorial here https://ryouready.wordpress.com/2013/11/20/sending-data-from-client-to-server-and-back-using-shiny/

Basically, in javascript you would have Shiny.onInputChange("jsvar", clickedLink) , and then you can treat jsvar as a regular reactive input, so in R you can observe ({saveToDb (input $ jsvar)}) (you will need to define saveToDb)

0
source share

All Articles