Please help by taking StockChart. Pinning three .json files as in the example , But does not work. The code is below:
www.jsfiddle.net/d8xwjxg7/2
You have an error in your code:
$.getJSON('http://www.iklimat.pl/'+name()+'.php', function (data) {
Should be:
$.getJSON('http://www.iklimat.pl/'+ name +'.php', function (data) {
Since name is a string not a function.
Also, this will not work in a JSFiddle since you cannot load files not from the site the javascript is running on without the endpoint you are accessing setting the access-allow-control-origin header.
EDIT:
I have sorted out the issue you were having getting data, however there is an issue with that data.
http://jsfiddle.net/d8xwjxg7/5/
Related
Objective
To generate CSV "export data" files from within Fortify, then download them.
Steps
Generate the (csv) export data using, that works fine:
https://SERVER:8443/ssc/api/v1/dataExports/action
Download the csv file using:
https://SERVER:8443/ssc/transfer/reportDownload.html - GET
Problem
I'm facing an issue with step 2, export being successfully generated. I can't seem to download them.
I'm requesting :
https://SERVER:8443/ssc/api/v1/fileTokens
with the payload : { fileTokenType : "REPORT_FILE" }
I obtain:
YzFmOWY4ZjMtZjU2MS00ZTU0XXXXXXXXXXXXX
Yet as per the documentation, I should get something like:
7e8d912e-2432-6496-3232-709b05513bf2
As a result when I attempt to GET my file with the following request:
https://SERVER:8443/ssc/transfer/reportDownload.html?mat=YzFmOWY4ZjMtZjU2MS00ZTU0XXXXXXXXXXXXX&id=449741
I get a 500 error.
Questions
What do you guys get when you request: https://SERVER:8443/ssc/api/v1/fileTokens?
Is the documentation not exactly correct?
If not, what do you reckon I am doing wrong?
Found the solution, the correct link is
dataExportDownload.html
instead of:
reportDownload.html
Any help will be appreciated.
I need to extract data from websites and found that node-unfluff does the job (see https://github.com/ageitgey/node-unfluff). There is two ways to call this module.
First, from command line which works!
Second, from node js which doesn't work.
extractor = require('unfluff');
data = extractor('test.html');
console.log(data);
Output : {"title":"","lang":null,"tags":[],"image":null,"videos":[],"text":""}
The data returns an empty json object. It appears like it cannot read the test.html.
It seems like it doesn't recognise test.html. The example says, "my html data", is there a way to get html data ? Thanks.
From the docs of unfluff:
extractor(html, language)
html: The html you want to parse
language (optional): The document's two-letter language code. This
will be auto-detected as best as possible, but there might be cases
where you want to override it.
You are passing a filename, and it expects the actual HTML of the file to be passed in.
If you are doing this in a scripting context, I'd recommend doing
data = extractor(fs.readFileSync('test.html'));
however if you are doing this in the context of a server or some time when blocking will be an issue, you should do:
fs.readFile('test.html', function(err, html){
var data = extractor(html);
console.log(data);
));
I am trying to used locally stored json files to pull in information, right now I am just hardcoding the json in a variable, but what I would like to do is point to some json files I have locally
something like -
var myData = "scripts/data/myData.json";
Is something like this possible?
Thanks!
You can do that in this way :
$http.get("scripts/data/myData.json").success(function(response) {
$scope.myData= response
}).error(function(err) {
alert(err);
})
Please see here working demo
http://plnkr.co/edit/dV1lHIZyoKYNDxbPwHNV?p=preview
I`m pretty sure that you can not make AJAX request to a file:// protocol.
On calling grid.parse(jsonstr, 'json') in js code the report is not getting displayed nor it throws any error though all the headers are getting displayed. Code below:
function getReportData(data) {
var gr = new dhtmlXGridObject('gridbox');
gr.selMultiRows = true;
gr.setHeader(data['tVals']['header']);
gr.setInitWidths(data['tVals']['init_widths']);
gr.setColAlign(data['tVals']['col_align']);
gr.setColTypes(data['tVals']['col_types']);
gr.setColSorting("str,str");
gr.init();
gr.parse(data['gData'], 'json');
}
PS: data has all the relevant information required by the code.
Also my html has following js imports:
dhtmlxcommon.js
dhtmlxgrid.js
dhtmlxgridcell.js
dhtmlxtreegrid.js
dhtmlxgrid_json.js
dhtmlxgrid_hextra.js
jquery version 1.6.1
The issue is seems to be in the format of your JSON. Can you provide a sample of your JSON string?
You can find an example of valid JSON supported by dhtmlxGrid here:
http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:syntax_templates#json_format_details
It would really help if you posted your JSON format, however I think I know what your problem is:
There are two formats of JSON that you can use in DHTMLX ( more details on https://docs.dhtmlx.com/grid__data_formats.html#jsonformat)
So the solution to your issue should be very simple.
Change
gr.parse(data['gData'], 'json');
to
gr.parse(data['gData'], 'js');
I am trying to create some JSON to be used for displaying a chart using Highcharts
http://www.highcharts.com/
I have copied one of their examples:
http://www.highcharts.com/stock/demo/basic-line
Click "View Options" under the graph to see the source. There is also a JSFiddle there to play with
If I copy that locally it all works fine.
The problem is when I try to use my own data source.
I have an ASP.Net MVC controler which is spitting out a list of arrays, just like their data source. However, that doesn't work.
Their datasource looks like this
http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?
and they retrieve it like this
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {
So I thought I'd take a step back and copy thier data exactly and put it in a text file on my server and try that:
So I tried this
$.getJSON('/data.txt', function (data) {
and this
$.get('/data.txt', function (data) {
but neither work
I have also tried using both JSON.parse and jQuery.parseJSON after retrieving the data, but again - that doesn't seem to work
I am also wondering what the ? is at the start of their data
Their data looks like this
?([[<some data>],[some data]]);
I don't get any error message, the graph just doesn't display
any ideas?
SOLVED IT
Just need to retrive the data and turn it into an array and pass it to the chart.
Needs to be an array, not JSON
That datasource is ouputting JSONP, which is for cross-domain AJAX requests. It's not valid 'raw' JSON because of that extra callback(...) wrapper.
Read up about it here: http://api.jquery.com/jQuery.ajax/ under the 'dataType' section.
As you say in your tags, it's not JSON, it's JSONP. Do not parse it, catch it with a callback. Use jQuery.getScript to do it, and define function callback(data). Inside that function, data should contain the (parsed) object. Also, replace the ? in the URL with callback (or whatever you named your function) - ? is not a valid identifier in JavaScript, so ?([....]) is nonsense.