Page 1 of 1

How to use readJson?

Posted: Tue Nov 10, 2015 12:59 pm
by Chan Kuan Leang
I am trying to load the data thru using post request from a url. But, somehow, it not able to read my json data.

Image

This is the error I always get. Is it due to the coding in my javascript?

From the google developer console, I can see my data is properly loaded.

Image

Wonder if I have done something wrong in my coding.

In the page header,

Code: Select all

       <script type="text/javascript">
			// StiOptions.WebServer.url = "handler.php";

			var options = new Stimulsoft.Designer.StiDesignerOptions();
			options.appearance.fullScreenMode = true;

			var report = new Stimulsoft.Report.StiReport(); 
			// report.loadFile("/public/reports/stockreceivedhcold.mrt"); //&param1=" + {{$rid}});
			var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false); 
			
			designer.report = report;
			designer.renderHtml("designerContent");

			// var report = new Stimulsoft.Report.StiReport(); report.loadFile("/public/reports/stockreceivedhc.mrt");
			// var viewer = new Stimulsoft.Viewer.StiViewer(null, "StiViewer", false); viewer.report = report;
			// viewer.renderHtml("viewerContent");
	</script>
In the footer of my page,

Code: Select all

	<script type="text/javascript">
		$(document).ready(function() {
			$.ajax({
		        url: 'getStockReceivedHCData/' + {{ $rid }},
		        type: 'POST',
		        data: { uniquecode: {{ $rid }} },
		        dataType: 'json',
		        statusCode: { 
		        	200:function(data){	
		        		var dataSet = new Stimulsoft.System.Data.DataSet("SimpleDataSet");
						dataSet.readJson(data);
						var report = new Stimulsoft.Report.StiReport();
						report.regData(dataSet.dataSetName, "", dataSet);
						var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false); 
		        		designer.renderHtml("designerContent");
		        		console.log(data);
		        	}
		        }
		    });
		});
	</script>

Re: How to use readJson?

Posted: Tue Nov 10, 2015 1:10 pm
by HighAley
Hello, Chan.

As you could get from error message there is an error in JSON.
Please, send us your JSON file for analysis.

Thank you.

Re: How to use readJson?

Posted: Tue Nov 10, 2015 1:16 pm
by Chan Kuan Leang
There is the sample file which I have copy the data from the google developer console.
I am using post ajax & get the data from an url.

Smile
Chan Kuan Leang

Re: How to use readJson?

Posted: Tue Nov 10, 2015 1:42 pm
by HighAley
Hello.

You have send us a Rich Text file with content as JSON file.
Such files are not supported.
Please, store JSON as plain text without any word processing software.

Thank you.

Re: How to use readJson?

Posted: Tue Nov 10, 2015 1:49 pm
by Chan Kuan Leang
Can this works?

Re: How to use readJson?

Posted: Tue Nov 10, 2015 2:13 pm
by HighAley
Dear Chan,

yes, this JSON file should work right.
Do you have any issue with it?

Thank you.

Re: How to use readJson?

Posted: Tue Nov 10, 2015 2:15 pm
by Chan Kuan Leang
As per the 1st post, 1st image.
I received that error message "JSON Parse Error".

Smile
Chan Kuan Leang

Re: How to use readJson?

Posted: Tue Nov 10, 2015 6:59 pm
by Andrew
Dear Chan Kuan Leang,

We were unable to reproduce the problem.

Please send us a sample to support@stimulsoft.com so that we could investigate the problem.

Waiting for your reply.
Thank you.

Re: How to use readJson?

Posted: Sun Nov 22, 2015 11:40 pm
by Chan Kuan Leang
Sorry for the long wait. I have just email my sample.

By the way, is there any sample on how to use post request from a url to send that json data?
Thanks.

Re: How to use readJson?

Posted: Mon Nov 23, 2015 1:37 pm
by HighAley
Hello.

We have received your message.
We will answer you by email when we get any result.

Thank you.