• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Foreign characters, Cdata and Ajax responseXML

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of our customers is from Slovenia, where they use a totally different charaectersset than we do [We use Western European]. All our code works perfectly on our own machines - but when deployed to customer site, some of the Ajax stuff starts to make trouble. First of all - I've encapsulated the Ajaz XML data in CDATA sections, like this:

<Rows>
<Row><![CDATA[A]]></Row>
<Row><![CDATA[B]]></Row>
<Row><![CDATA[C]]></Row>
</Rows>

Now when I recieve the data on the client side - I'd like to test how many "Row" element is present. Normally I would use something like this:

numOfRows = xmlDoc.getElementsbyName("Row").length

- and expect to get something like 3 in return, but instead I recieve an exception - "object is null or....."

Question 1: Is the CDATA - the way to work around special characters in XML/Ajax?
Question 2: How do I get the number of rows, based on the code above?
Question 3: What could be the explanation to why the code works ok on our site - and not on the Customer site - when the code is the same - and the browser used [IE8] is the same (run via VPN) ?

Any help will be greatly appreciated.

Thanks, Henrik
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you setting the correct encodings?

Eric
 
Henrik Krievs
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well , I think so:

I've put this on top of the XML document:

<?xml version="1.0" encoding="UTF-8"?>

- But if this will work with Slovenia characters, I can't say...
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I would hardly describe those Eastern European characters as "totally different" from those Western European characters. But anyway, UTF-8 will support every single character known to Unicode. So not only Western and Eastern European characters, but also Greek and Chinese and Malayalam and even a lot of scripts which nobody ever heard of.

And in particular there are no "special characters" when you use UTF-8. They are all just characters. So there's nothing to "work around" in that case.

So, you really ought to get down to finding out what's going on. You can't just stand by and blame the script. For example, does your code fail even if only ASCII characters are used? Does the server receive the data that you expect it to receive? Does it send the data you expect it to send? Does anything work, or does nothing work? You're going to need details to find out what's wrong -- or at least we are.
 
Henrik Krievs
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've checked everything.

It seems like the browser receives the correct data (checked that via Fiddler). So the error occours somewhere in the javascript part.

It's only the ajax part that doesn't work - regular pages is showing ok.

I'm sorry I can't narrow it more down....
reply
    Bookmark Topic Watch Topic
  • New Topic