Actually i am following this question of stackoverflow
Embedding an R htmlwidget into existing webpage
The above question shows two methods to embedd a graph
- Php
- Jquery
Currently i am using jQuery ajax method to embed the json it works but on second ajax request graph does't updated. But when i reload the page the graph will be updated. So i want to update the graph without reloading the whole page.
** Updating data.json**
jQuery.ajax({
url : '/modules/multistep_form/plotlyjson/775_graph2_data.json',
beforeSend : function() {
},
type : 'POST',
cache : false,
success : function(data) {
//console.log(data);
// $("#data-json-graph2").text("");
console.log($("#data-json-graph2").text(""));
$("#data-json-graph2").append(JSON.stringify(data));
setTimeout(function(){
window.HTMLWidgets.staticRender();
Drupal.attachBehaviors();
}, 1000);
},
error : function(xhr, status, error) {
// executed if something went wrong during call
if (xhr.status > 0)
alert('got error: ' + status);
}
});
**Updating style.json**
jQuery.ajax({
url : '/modules/multistep_form/plotlyjson/775_graph2_style.json',
beforeSend : function() {
},
type : 'POST',
cache : false,
success : function(data) {
//console.log(data);
//$("#style-json-graph2").text("");
console.log($("#style-json-graph2").text(""));
$("#style-json-graph2").append(JSON.stringify(data));
setTimeout(function(){
window.HTMLWidgets.staticRender();
Drupal.attachBehaviors();
}, 1000);
},
error : function(xhr, status, error) {
// executed if something went wrong during call
if (xhr.status > 0)
alert('got error: ' + status);
}
});