• 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

Javascript error : help

 
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does

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

Look like when the page is rendered?

Eric
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got javascript error : ']' expected
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic