How to use readJson?

Stimulsoft Reports.JS discussion
Post Reply
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

How to use readJson?

Post 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>
Smile
Chan Kuan Leang
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to use readJson?

Post 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.
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Re: How to use readJson?

Post 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
Attachments
sample.json.zip
(1.43 KiB) Downloaded 589 times
Smile
Chan Kuan Leang
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to use readJson?

Post 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.
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Re: How to use readJson?

Post by Chan Kuan Leang »

Can this works?
Attachments
sample.json.zip
(1.23 KiB) Downloaded 618 times
Smile
Chan Kuan Leang
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to use readJson?

Post by HighAley »

Dear Chan,

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

Thank you.
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Re: How to use readJson?

Post by Chan Kuan Leang »

As per the 1st post, 1st image.
I received that error message "JSON Parse Error".

Smile
Chan Kuan Leang
Smile
Chan Kuan Leang
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Re: How to use readJson?

Post 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.
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Re: How to use readJson?

Post 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.
Smile
Chan Kuan Leang
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to use readJson?

Post by HighAley »

Hello.

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

Thank you.
Post Reply