Date:  11/27/2007 07:15:50 PM Msg ID:  003605
From:  G Barfield Thread:  003600
Subject:  Re: JSon Write Problem
The javascript program gives no error, it just doesn't do anything (it is supposed to pop up the suggestions under the input field.

Here is the code:

LOCAL Employee

SearchZip = Request.QueryString("input")

SELECT id, ALLTRIM(lastname)+", "+ALLTRIM(firstname) as value, ALLTRIM(firstname) as info;

FROM d:\ajax\employee;

WHERE ALLTRIM(LastName) LIKE SearchZip + "%";INTO CURSOR SomePeople

Response.ContentType = "text/plain"

*!* Response.Write('{"results":[{"id":2,"value":"Johnson, Tim","info":"Tim"},{"id":9,"value":"Johnson, Jeremy","info":"Jeremy"}]}')

Response.Write('{"results":' + SUBSTR(fwJSON.WriteCursor(), AT(":",fwJSON.WriteCursor(),2)))

The code that is commented out actually works.  If you uncomment this code and comment out the other one, the suggestion box pops up.   I got the string by running the program in its own browser by copying the URL into the address bar; the resulting string looks exactly like what the progam needs and in fact, works if you past the string into the Response.Write().

Everything else is the same.

Thanks in advance for your help.

Sent by FoxWeb Support on 11/27/2007 06:02:30 PM:
What do you mean by "my javascript program won't accept it?"  Are you getting an error message?  What's the text?

The reason why it works in the second case may be completely unrelated to the fact that you are pasting the text in a string literal instead of generating it on the fly via the fwJSON object.  Is everything else equal?  Could it be that you are sending a different content type, or charset HTTP header?
FoxWeb Support Team email
Sent by G Barfield on 11/25/2007 02:07:04 PM:
I am trying to use JSon(WriteCursor) to write a JSon string back to a javascript program for a AutoComplete feature in a form.   I finally got my JSON string formatted correctly (with the help of Pandelis) and thought it was working but my javascript program won't accept it.

Wierd part is, when I cut and paste the string contents out and put it directly into Response.Write("String Content") the program works, but will not work "on the fly".   String content must be in quotes for it to work but of course you can't put the function in quotes or it is literally translated.

Does anyone have any ideas?