I need to save a response made by a @restcontroller in a javascript variable.
you can get the response by invoking an URL like localhost:8080/JSORresponse
and you will get a JSON .
how can i save that json in a javascript dataObject to use it as a source in a library?
Thanks, ask if not clear or you need more details
OLD EDIT - I've got this code:
var beer;
$.getJSON("http://localhost:8080/timeline",function(json){
beer = json;
checkDrink();
});
function checkDrink() {
console.log(JSON.stringify(beer));
}
var beerS = JSON.stringify(beer);
var timeline_config = {
width: "100%",
height: "100%",
source: beerS
}
console.log(JSON.stringify(beer)); log the exactly JSON i want to save in my beerS variable, but when i use it seems not to work, some advice to save that exact log result into a variable and pass it in the timeline_config?
NEW UPDATE - that's the new checkpoint
var beer;
$.getJSON("http://localhost:8080/timeline",function(json){
beer = json;
checkDrink();
});
function checkDrink() {
console.log(JSON.stringify(beer));
var beerS = JSON.stringify(beer)
var timeline_config = {
width: "100%",
height: "100%",
source: beer
}
}
but now i got all white page, that's the DOC of the library maybe can help
Source
source Should be either the path to the JSON resource to load, or a JavaScript object corresponding to the Timeline model.
Here is an example using a data object:
var dataObject = {timeline: {headline: "Headline", type: ... }}
createStoryJS({
type: 'timeline',
width: '800',
height: '600',
source: dataObject,
embed_id: 'my-timeline'
});
If source is a string, we will try to automatically recognize resources that are Twitter searches, Google Spreadsheets or Storify stories. Failing that, we assume the source is either JSON or JSONP. If string matches on .jsonp, we will treat it as JSONP, otherwise, we will append ?callback=onJSONP_Data. See more details below.
i have also tried using beer and beerS but result remains the same