GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Javascript error : help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Javascript error : help" Watch "Javascript error : help" New topic
Author

Javascript error : help

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jul 07, 2005
Posts: 510

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
What does

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

Look like when the page is rendered?

Eric
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

I got javascript error : ']' expected
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jul 07, 2005
Posts: 510

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

Joined: Jul 07, 2005
Posts: 510

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.
 
wood burning stoves
 
subject: Javascript error : help