View Complete Thread | FoxWeb Forum Home
Search:
Date:    Msg ID:   
From:    Thread:   
Subject:   
Hello Fernando,
 
I have the same problem in French. I triedmany option, urlencode ...
The way I solve the problem is using the strtran() function in the procedure.
Please find the code below using the zipsearch sample.
Don't forget that the cursor needs to be readwrite. 
Just add any code if there are not in the list, also delete some you don't need.
 
The  ZIPSEARCH.FWX no changes.
 
Just replace the code from ZipSearchAjax.prg  with the one below.
 
***** code starts here *******
 
 
#DEFINE MAX_RESULTS 100        && Maximum number of zip codes that this script will return

LOCAL AjaxResponse, SearchZip

* Force HTTP 500 status code in the case of a script error
fwError.ErrorStatus500 = .T.

* Read the search string from the query string
SearchZip = Request.QueryString("zip")

* Create an object, which will be serialized to JSON format in our response
AjaxResponse = CREATEOBJECT("Custom")
* Add a property that will indicate whether the script returned search results
AjaxResponse.AddProperty("Zip", SearchZip)
* Add a property that will indicate whether the script returned search results
AjaxResponse.AddProperty("HasResults", .F.)
* Add a property that will indicate the number of matching zip codes
AjaxResponse.AddProperty("ResultsCount", 0)

IF NOT EMPTY(SearchZip)
    SELECT * FROM ZipCodes ;
        WHERE zip LIKE SearchZip + "%" ;
        ORDER BY zip ;
        INTO CURSOR SearchResults READWRITE

REPLACE ALL city WITH STRTRAN(city,"!","!")
REPLACE ALL city WITH STRTRAN(city,"_","_")
REPLACE ALL city WITH STRTRAN(city,"Û","Û")
REPLACE ALL city WITH STRTRAN(city,"®","®")
REPLACE ALL city WITH STRTRAN(city,"    ",""")
REPLACE ALL city WITH STRTRAN(city,"`","`")
REPLACE ALL city WITH STRTRAN(city,"Ü","Ü")
REPLACE ALL city WITH STRTRAN(city,"#","#")
REPLACE ALL city WITH STRTRAN(city,"Ý","Ý")
REPLACE ALL city WITH STRTRAN(city,"Þ","Þ")
REPLACE ALL city WITH STRTRAN(city,"ß","ß")
REPLACE ALL city WITH STRTRAN(city,"¢","¢")
REPLACE ALL city WITH STRTRAN(city,"à","à")
REPLACE ALL city WITH STRTRAN(city,"£","£")
REPLACE ALL city WITH STRTRAN(city,"á","á")
REPLACE ALL city WITH STRTRAN(city,"¤","¤")
REPLACE ALL city WITH STRTRAN(city,"â","â")
REPLACE ALL city WITH STRTRAN(city,"¥","¥")
REPLACE ALL city WITH STRTRAN(city,"ã","ã")
REPLACE ALL city WITH STRTRAN(city,"Â","Â")
REPLACE ALL city WITH STRTRAN(city,"¦","¦")
REPLACE ALL city WITH STRTRAN(city,"ä","ä")
REPLACE ALL city WITH STRTRAN(city,"Ã","Ã")
REPLACE ALL city WITH STRTRAN(city,"§","§")
REPLACE ALL city WITH STRTRAN(city,"å","å")
REPLACE ALL city WITH STRTRAN(city,"Ä","Ä")
REPLACE ALL city WITH STRTRAN(city,"æ","æ")
REPLACE ALL city WITH STRTRAN(city,"Å","Å")
REPLACE ALL city WITH STRTRAN(city,"©","©")
REPLACE ALL city WITH STRTRAN(city,"ç","ç")
REPLACE ALL city WITH STRTRAN(city,"Æ","Æ")
REPLACE ALL city WITH STRTRAN(city,"ª","ª")
REPLACE ALL city WITH STRTRAN(city,"è","è")
REPLACE ALL city WITH STRTRAN(city,"Ç","Ç")
REPLACE ALL city WITH STRTRAN(city,"é","é")
REPLACE ALL city WITH STRTRAN(city,"È","È")
REPLACE ALL city WITH STRTRAN(city,"¬","¬")
REPLACE ALL city WITH STRTRAN(city,"ê","ê")
REPLACE ALL city WITH STRTRAN(city,"É","É")
REPLACE ALL city WITH STRTRAN(city,"ë","ë")
REPLACE ALL city WITH STRTRAN(city,"Ê","Ê")
REPLACE ALL city WITH STRTRAN(city,"®","®")
REPLACE ALL city WITH STRTRAN(city,"ì","ì")
REPLACE ALL city WITH STRTRAN(city,"Ë","Ë")
REPLACE ALL city WITH STRTRAN(city,"¯","¯")
REPLACE ALL city WITH STRTRAN(city,"í","í")
REPLACE ALL city WITH STRTRAN(city,"Ì","Ì")
REPLACE ALL city WITH STRTRAN(city,"°","°")
REPLACE ALL city WITH STRTRAN(city,"î","î")
REPLACE ALL city WITH STRTRAN(city,"Í","Í")
REPLACE ALL city WITH STRTRAN(city,"±","±")
REPLACE ALL city WITH STRTRAN(city,"ï","ï")
REPLACE ALL city WITH STRTRAN(city,"Î","Î")
REPLACE ALL city WITH STRTRAN(city,"²","²")
REPLACE ALL city WITH STRTRAN(city,"ð","ð")
REPLACE ALL city WITH STRTRAN(city,"Ï","Ï")
REPLACE ALL city WITH STRTRAN(city,"³","³")
REPLACE ALL city WITH STRTRAN(city,"ñ","ñ")
REPLACE ALL city WITH STRTRAN(city,"Ð","Ð")
REPLACE ALL city WITH STRTRAN(city,"ò","ò")
REPLACE ALL city WITH STRTRAN(city,"Ñ","Ñ")
REPLACE ALL city WITH STRTRAN(city,"µ","µ")
REPLACE ALL city WITH STRTRAN(city,"ó","ó")
REPLACE ALL city WITH STRTRAN(city,"Õ","Õ")
REPLACE ALL city WITH STRTRAN(city,"¶","¶")
REPLACE ALL city WITH STRTRAN(city,"ô","ô")
REPLACE ALL city WITH STRTRAN(city,"Ö","Ö")
REPLACE ALL city WITH STRTRAN(city,"õ","õ")
REPLACE ALL city WITH STRTRAN(city,"Ø","Ø")
REPLACE ALL city WITH STRTRAN(city,"ö","ö")
REPLACE ALL city WITH STRTRAN(city,"Ù","Ù")
REPLACE ALL city WITH STRTRAN(city,"¹","¹")
REPLACE ALL city WITH STRTRAN(city,"Ú","Ú")
REPLACE ALL city WITH STRTRAN(city,"º","º")
REPLACE ALL city WITH STRTRAN(city,"ø","ø")
REPLACE ALL city WITH STRTRAN(city,"Û","Û")
REPLACE ALL city WITH STRTRAN(city,"ù","ù")
REPLACE ALL city WITH STRTRAN(city,"Ü","Ü")
REPLACE ALL city WITH STRTRAN(city,"@","@")
REPLACE ALL city WITH STRTRAN(city,"~","~")
REPLACE ALL city WITH STRTRAN(city,"¼","¼")
REPLACE ALL city WITH STRTRAN(city,"ú","ú")
REPLACE ALL city WITH STRTRAN(city,"Ý","Ý")
REPLACE ALL city WITH STRTRAN(city,"½","½")
REPLACE ALL city WITH STRTRAN(city,"û","û")
REPLACE ALL city WITH STRTRAN(city,"Þ","Þ")
REPLACE ALL city WITH STRTRAN(city,"¾","¾")
REPLACE ALL city WITH STRTRAN(city,"ü","&#252")
REPLACE ALL city WITH STRTRAN(city,"ß","ß")
REPLACE ALL city WITH STRTRAN(city,"ý","ý")
REPLACE ALL city WITH STRTRAN(city,"à","à")
REPLACE ALL city WITH STRTRAN(city,"À","À")
REPLACE ALL city WITH STRTRAN(city,"þ","þ")
REPLACE ALL city WITH STRTRAN(city,"á","á")
REPLACE ALL city WITH STRTRAN(city,"Á","Á")
REPLACE ALL city WITH STRTRAN(city,"ÿ","ÿ")
REPLACE ALL city WITH STRTRAN(city,"å","å")
REPLACE ALL city WITH STRTRAN(city,"Â","Â")
REPLACE ALL city WITH STRTRAN(city,"æ","æ")
REPLACE ALL city WITH STRTRAN(city,"Ã","Ã")
REPLACE ALL city WITH STRTRAN(city,"ç","ç")
REPLACE ALL city WITH STRTRAN(city,"Ä","Ä")
REPLACE ALL city WITH STRTRAN(city,"è","è")
REPLACE ALL city WITH STRTRAN(city,"Å","Å")
REPLACE ALL city WITH STRTRAN(city,"é","é")
REPLACE ALL city WITH STRTRAN(city,"Æ","Æ")
REPLACE ALL city WITH STRTRAN(city,"ê","ê")
REPLACE ALL city WITH STRTRAN(city,"Ç","Ç")
REPLACE ALL city WITH STRTRAN(city,"ë","ë")
REPLACE ALL city WITH STRTRAN(city,"È","È")
REPLACE ALL city WITH STRTRAN(city,"ì","ì")
REPLACE ALL city WITH STRTRAN(city,"É","É")
REPLACE ALL city WITH STRTRAN(city,"í","í")
REPLACE ALL city WITH STRTRAN(city,"î","î")
REPLACE ALL city WITH STRTRAN(city,"Ë","Ë")
REPLACE ALL city WITH STRTRAN(city,"ï","ï")
REPLACE ALL city WITH STRTRAN(city,"Ì","Ì")
REPLACE ALL city WITH STRTRAN(city,"ð","ð")
REPLACE ALL city WITH STRTRAN(city,"Í","Í")
REPLACE ALL city WITH STRTRAN(city,"ñ","ñ")
REPLACE ALL city WITH STRTRAN(city,"Î","Î")
REPLACE ALL city WITH STRTRAN(city,"ò","ò")
REPLACE ALL city WITH STRTRAN(city,"Ï","Ï")
REPLACE ALL city WITH STRTRAN(city,"ó","ó")
REPLACE ALL city WITH STRTRAN(city,"Ð","Ð")
REPLACE ALL city WITH STRTRAN(city,"ô","ô")
REPLACE ALL city WITH STRTRAN(city,"Ñ","Ñ")
REPLACE ALL city WITH STRTRAN(city,"õ","õ")
REPLACE ALL city WITH STRTRAN(city,"Ò","Ò")
REPLACE ALL city WITH STRTRAN(city,"ö","ö")
REPLACE ALL city WITH STRTRAN(city,"Ó","Ó")
REPLACE ALL city WITH STRTRAN(city,"ø","ø")
REPLACE ALL city WITH STRTRAN(city,"Ô","Ô")
REPLACE ALL city WITH STRTRAN(city,"ù","ù")
REPLACE ALL city WITH STRTRAN(city,"Õ","Õ")
REPLACE ALL city WITH STRTRAN(city,"ú","ú")
REPLACE ALL city WITH STRTRAN(city,"Ö","Ö")
REPLACE ALL city WITH STRTRAN(city,"û","û")
REPLACE ALL city WITH STRTRAN(city,"ý","ý")
REPLACE ALL city WITH STRTRAN(city,"Ø","Ø")
REPLACE ALL city WITH STRTRAN(city,"þ","þ")
REPLACE ALL city WITH STRTRAN(city,"Ù","Ù")
REPLACE ALL city WITH STRTRAN(city,"ÿ","ÿ")
REPLACE ALL city WITH STRTRAN(city,"^","^")
REPLACE ALL city WITH STRTRAN(city,"Ú","Ú")

    AjaxResponse.ResultsCount = RECCOUNT()
ELSE
    AjaxResponse.ResultsCount = 0
ENDIF
IF BETWEEN(AjaxResponse.ResultsCount, 1, MAX_RESULTS)
    * Add a property, whose value is an object of type fwCursor, pointing to the SearchResults cursor
    * The fwJSON.Write method will serialize the contents of the cursor into the JSON string
    AjaxResponse.HasResults = .T.
    AjaxResponse.AddProperty("ZipCodes", CREATEOBJECT("fwCursor", "SearchResults"))
ENDIF
Response.ContentType = "text/plain"
Response.Write(fwJSON.Write(AjaxResponse))
 
***** code end ***** 
 
 
That's it ! 
 Bye
Jean-charles
jc_clerc@hotmail.com 
 
   
 
Sent by Fernando Medan on 11/01/2007 04:44:55 AM:
I use the example ZIPSEARCH.FWX (FoxWeb 4.0)
If change my name "Santa Monica" for  "Santa Mónica" in the table Zipcodes.dbf, CP=90402, looks like the following:

Incremental ZIP Code Search with FoxWeb and AJAX

Zip Code Search:
CPCiudadEstado
90401 Santa Monica CA
90402 Santa M?a CA
90403 Santa Monica CA

Is there any way to correct this error?
Thank you for your help,
Fernando Medan


Sent by FoxWeb Support on 10/31/2007 10:00:31 AM:
You can transfer international characters, but you will need to encode them in the right format.  I believe that this will be different, depending on the transport mechanism.  Are you having problems sending such characters from the browser to the server, or the other way around?  Are you sending data to the server via a GET request (query string), or POST?  When returning data to the browser, are you using XML, JSON, or something else?
FoxWeb Support Team
support@foxweb.com email
Sent by Fernando Medan on 10/31/2007 04:30:03 AM:
There is some way to use the diacriticals characters (ñ, á, é, etc.) with AJAX?
Thanks.