struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: [OT] AJAX (XMLHTTP) doesn't work with Ampersand
Date Tue, 06 Sep 2005 14:28:17 GMT
Let me see if I'm all caught up here (I'm just back to work from vacation
today, so my brain isn't fully engaged yet)...

Everything works as expected up until the point you try to populate the
dropdown on the client, correct?  The XML you get back from the servlet is
correct, so the problem lies somewhere in the code to populate the
dropdown.  Sound about right?

If so, can you post said code?  We might be able to spot something there. 
Off-hand I can't think of what the problem might be, I don't think I've
ever seen this before... I did see some issues with internationalized data
at one point, but ampersand I don't think falls in that category.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Tue, September 6, 2005 10:16 am, bjester_2004@yahoo.com said:
> Gareth, you are correct abut ajax being independent.  In my case, the
> interesting thing is that the servlet is using database to look up the
> data and requires where cause as a parameter so that it can generate a
> query, retrieve data from database, create xml to be passed to the calling
> .jsp page.:
>
> i.e.: here are the steps
>
> 1. onchange()  getdataValues.jsp?state='NY'
> 2. in servlet, ( multiple checks...)
>  if (state != null && state.length() > 0)
>  {
>    searchFor = "COUNTRY_ID, COUNTRY_NAME";
>    whereIs= "STATE = '" + state + "'";
>  }
>
> sql =  "SELCT " + searchFor  + " FROM DATA_TABLE WHERE " + whereIs;
>
> 3. compile data from that query to xml and return to browser.
>
> In this case, the database holds the ampersand.  not the parameters that
> are passed to the servlet.  When I print out the results that the servlet
> rturned.  It looks like this:
> <?xml version="1.0" encoding="UTF-8" ?><root><dataSet dataID="USA"
> dataValue="United States & US Vargin Islands" /><dataSet dataID="AUS"
> dataValue="Australia" /></root>
>
> The drop down populates when I delete the USA record from the database.
> So, it seems that the data that is returned needs to be parsed somehow
> before AJAX can parse and populate the country dropdown.  Does this help?
>
>
> Gareth Evans <gareth.evans@msoft.co.uk> wrote:
> Hi Bob,
>
> Even so, the request that your making to your 'ajax servlet', the url
> depends on the value of the
> first select box. Somthing like 'myajaxservlet?firstvalue=Australia'
>
> are you building this url in javascript before making the request? thats
> the point at which you want
> to encode it. If you are doing it this way, the servlet will be unable to
> handle the request as you
> expected because it will take "United States" and "US Vargin Islands" as
> separate parameters rather
> than a single one. Why? because '&' is used as the delimeter. If you use
> the javascript escape
> function e.g javascript:escape('United States & US Vargin Islands'), your
> servlet will handle this
> as a single parameter.
>
> It doen't matter that your not using struts, ajax is independant of your
> servlet side code, it could
> be written in asp if you are that way inclined ;-)
>
> Gareth
>
>
> ---------------------------------
>  Click here to donate to the Hurricane Katrina relief effort.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message