Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Rick Mendes on May 21, 2009 13:30
open dhtmlx forum
Grid load function, JSON, Accept Header

Hello,

I am currently evaluating your product for potential use on several applications we will be developing. So far things have been going well. However, I did run into one problem with the grid load function and JSON.

We build all of our applications using Ruby on Rails. Rails has automatic detection of the accepted content. This works perfectly with XML calls. However, when we try JSON calls, Rails still thinks the accepted content is XML. I dumped the headers on the back-end and the same Accept header is being sent for XML and JSON. I expected the JSON call to use application/json. I tested that with curl and Rails detects JSON with it.

Is this a bug or do you have a reason for making JSON calls look like XML?

My calls look like this:
mygrid.load("/products/");
mygrid.load("/products/", "json");

I am using the following release for my evaluation.
dhtmlxSuite 2009 Rel.1 (DHTMLX 2.1) Standard edition build 90226

Thank you.
Answer posted by Support on May 22, 2009 02:44
The component uses common loading routine for all data types, it is just a raw xmlHTTPRequest without any additional headers. 
The call uses the same Accept header as for any other HTTP call ( text/html,application/xhtml+xml,application/xml ) - this data is set by a browser itself. 

Basically - data loading request doesn't have any additional info about awaited response type ( it is quite common solution, and part of RESTl ideology, promoted by RoR, that type and content of  response fully defined by URL, not by additional headers ) 
Answer posted by Rick Mendes on May 26, 2009 13:22
Thanks for the reply.

I was able to get this working using your url suggestion.

For example:
mygrid.load("/products.json", "json");

That works perfectly.

Rick