This is a migrated thread and some comments may be shown as answers.

Using Template For Returned JSON Data From Server

2 Answers 130 Views
Window
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 31 May 2013, 10:55 PM
Hi!

I was looking at the Window component documentation. There is a request option called "template". I am assuming this template can be used to format JSON data returned from the server. So, the template I used was the following:
"#= html #"
The data returned from the server is something like:
"html": "<span>Hello world!</span>",
"instanceId": "10A",
"data": null
However, I always get a Javascript error that says "ReferenceError: html is not defined".

Any ideas why html is not defined though it comes in the response body?

Regards.

2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 05 Jun 2013, 06:17 AM
Hi Luis,

 
Thank you for bringing this issue to our attention. I have informed our dev team about it and it will be fixed in next internal builds.

You can use the workaround below until we get this issue fixed:

//data is the received object, html is the needed property
//use the JSON.parse to parse the received JSON
template: "#=JSON.parse(data).html#"

As a small sign of our appreciation I have updated your Telerik points. Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Luis
Top achievements
Rank 1
answered on 05 Jun 2013, 03:00 PM
Thanks for the reply, Vladimir. However, someone answered this exact same question 2 days ago as I posted it on StackOverflow as well.

Apparently, all you have to do is set the dataType as JSON. See the following answer for an example: Data Type Json

Regards.
Tags
Window
Asked by
Luis
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Luis
Top achievements
Rank 1
Share this question
or