OECGI2, Ajax, JSON and Firefox (OpenInsight 32-Bit)
At 26 FEB 2008 02:28:22PM Enrique Murphy wrote:
Hi.
I have built my own framework in OI to provide HTML interface to OI applications. The framework generates HTML with calls to javascript functions that perform Ajax ICONV/OCONV and dinamically build "edit tables" for MVs. I am generating JSON responses to XHR requests instead of XML (as Bob Carten suggested me some time ago).A JSON string is returned from OI as a response to an Ajax call in the "onblur" event to perform ICONV. The response text is evaluated to get the result (the output value or the error message) using the javascript eval function. In FireFox, the response to the Ajax request it is received with a trailing Char(0), as I could find out using FireBug, so the javascript eval fails, and thus the ICONV/OCONV. The same response is correctly received and evaluated in IE and Opera.I am using OI 8.0.3, OECGI2, and IIS 5.0. The OI application runs in ANSI mode. I have the charset of the HTML pages set to ANSI (ISO-8859-1), but I am converting the response to Ajax calls to UTF-8, using the ANSI_UTF8 function.By the moment, I have solved this problem using a try-catch sentence to eval the response, stripping the last character of the response text in the catch block. This makes it work in FF, but I would like to know why FF receives from OI a char(0) as the last character of the string, instead of recognizing char(0) as the end of the string.I don't know if the problem is caused by the header of the OECGI2 response, or by something that Firefox is expecting differently, or a combination of both. I am not appending a char(0) to the response, so I suppose OECGI is doing it.Enrique
At 26 FEB 2008 05:49PM Martin Drenovac wrote:
Enrique / Bob - I'd be very keen to be across these developements as this is exactly the approach I'm adopting albeit via RoR & Apache.
Thank you
At 27 FEB 2008 08:46AM Bob Carten wrote:
I'll look at Enrique's issues, but I'm not as experienced with Ajax as some others in the community. David Goddard has done some great things with Ajax, I believe Sprezzatura have a lot of experience, I'm sure others do too. The WebOI package ( nee' FreedomBase ) is Ajax based.
I like the idea of OI sitting behind Ruby on Rails. I had a discussion with a potential customer who inherited a MySql implementation ( not ruby on rails) who feels he can halve his development costs if he moves to OI.
- Bob
At 27 FEB 2008 09:23AM Enrique Murphy wrote:
Hi, Martin. RoR against OI?. I know little about RoR, but I can't figure out how would you make the connection to the OI databases, specially with MVs.
At 27 FEB 2008 09:37AM Enrique Murphy wrote:
Is anyone returning JSON from OI?. As I said in the first post, I can't see where the problem may reside. All I know is that Firefox shows me the received text string with a zero char at the end. Maybe something with the charset, or OECGI2 appending an extra zero char. I tried with FF 1.5, 2 and the 3 beta, and is the same with all of them.
At 27 FEB 2008 12:10PM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
Enrique,
Our Ajax framework uses JSON for data transfer requests. The primary browser I use for development is Firefox and I've seen no issues of the sort you describe. Saying that I've been using FF2 for some time so I couldn't say for certain if there's an issue in 1.5
The fact that IE and Opera are fine seems to point to an FF issue rather than an OECGI one? To narrow it down some more, do you get the same issue with OECGI as opposed to OECGI2? (they are very different internally and have different code bases).
Have you used something like "TamperData" or "Live HTTP Headers" to see what the browser is being sent?
The JSON we send back is encoded to UTF8 with a content-type of text/plain.
World leaders in all things RevSoft
At 27 FEB 2008 12:28PM Enrique Murphy wrote:
I am not setting the Content-Type. I am just returning the JSON string as the response, after converting it to UTF8. I tried returning Content-Type:application/json and the Content-Length, but it didn't seem to work. Can you change the content-type of what is being returned, by returning Content-type and content-length?.
I will also try with OECGI to see if it goes wrong, and let you know.
At 27 FEB 2008 02:16PM Enrique Murphy wrote:
The problem is with OECGI2. OECGI returns the string without the trailing zero character, and then FF evaluates it without any problem.
OECGI2 is apparently appending a zero char to the response.