File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript error : help

 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
in a jsp page I have an automatically html generated string :


i need to call it from javascript method like this :

this doesn't work and i ot error: string not terminated.

actually this html String is generated automatically from a method i'm calling to return the above html string .
i've tried replacing all double qotes " in html by a single quote ' ; but this still generates a javascript error ( expected ']' ).

i tried using double quotes in javasript function like this :

and it now gives an error : expected ']' and not error : string not terminated.

I'm puzzeled what could be the problem ! I scanned the above html string and i didn't found any character that might confuse the browser.

can you help please ?

many thanks.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use single quotes since the string contains " all over.
You probably have to replace all of the line feeds on the server side.

Eric
[ March 20, 2006: Message edited by: Eric Pascarello ]
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried to replace all '\n' but i got the same problem.

do u mean i need to replace all " with ' ? i did that but i got same problem !

can someone help please ?

thanks.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does

alert ("<%=html%>");

Look like when the page is rendered?

Eric
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got javascript error : ']' expected
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
What does

alert ("<%=html%>");

Look like when the page is rendered?

Eric


That means what was the view source generated HTML look like..... Not the error....

Eric
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:


That means what was the view source generated HTML look like..... Not the error....

Eric


nothing is genarated a blank page !
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay guys i figuered out how to solve the problem ...

the trick was to replace all '\n' and '\r' with ""
i was replacing '\n' but i forgot to do so for '\r'
when i removed those two chars it worked fine

thank you for your time and support.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic