0
我想在按鈕的提交事件發佈一些數據閃亮的服務器。我已經完成了輸入綁定,但我無法接收我的html和服務器代碼所在的服務器上的數據。如何發送數據到服務器上點擊閃亮的按鈕
<html>
<script>
var submit_binding = new Shiny.InputBinding();
$.extend(submit_binding, {
find: function(scope) {
return $(scope).find("#submit");
},
getValue: function(el) {
// Get the row and cell number of the selected td.
//var month
//var year
var result = ['2', '2013'];
return result;
},
subscribe: function(el, callback) {
$(el).on("click.submit_binding", function(e) {
callback();
});
},
unsubscribe: function(el) {
$(el).off(".submit_binding");
}
});
Shiny.inputBindings.register(submit_binding);
</script>
<body>
<div>
<select id="mn" name="mn">
<option value="1">1</option>
<option value="2">2</option>
</select>
<select id="yr" name="yr">
<option value="2012">2012</option>
<option value="2013">2013</option>
</select>
<button id="submit">Run</button>
</div>
<div>
<div id="mean" class="d3-plot-output"></div>
</div>
</body>
</html>
我的服務器代碼:
shinyServer(function(input, output) {
month <- reactive({
switch(input$mn, '1'=1, '2'=2,1)
})
year <- reactive({
switch(input$yr, '2012'=2012, '2013'=2013,2012)
})
testwrite <- function(){
a = c[1,2,3]
write.csv(a, file="test_binding.csv");
return (a)
}
output$mean <- reactive(
testwrite()
)
})
我無法弄清楚什麼我在這裏失蹤。
究竟是什麼你想在這裏做什麼?我不認爲你需要綁定來在服務器和客戶端之間進行通信。如果你澄清你正在嘗試做什麼,有人可以提供幫助。 – Ramnath
我有一個html頁面,我有一個選擇框並提交按鈕。在做出選擇並點擊提交按鈕後,我將發送選擇框值到服務器。服務器將運行一些功能,並將結果發送回客戶端。客戶將使用d3js繪製一些圖表。 – user114037
Shiny已經爲此提供了一個提交按鈕。這不足以達到你的目的嗎? – Ramnath