Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
actually i have retrieve data from xml to html and put in marquee scrolling i have written code but not working please follow below code

this is xml
<company>
<staff>
<month>12
<date>31
<message>"If you are ready to believe, you are easy to deceive"


<staff>
<month>12
<date>30
<message>"Before you can score you must first have a goal."


<staff>
<month>12
<date>29
<message>"Before you can score you must first have a goal."




<staff>
<month>12
<date>28
<message>"If you are ready to believe, you are easy to deceive"


<staff>
<month>12
<date>27
<message>"All the flowers of tomorrow are in the seeds of yesterday"



<staff>
<month>12
<date>26
<message>"Before you can score you must first have a goal."



<staff>
<month>12
<date>25
<message>"If you want to be respected, you must respect yourself."




this is javascript i have written but not working
for (i=0;i
Posted

1 solution

You misunderstood the format of the for statement. With your code, JavaScript lexical parsing will give you the exception like "
SyntaxError:
missing ; after for-loop condition
(Actual error object depends on JavaScript implementation.)
If you remove "i" after first ';', it will be
JavaScript
SyntaxError:
expected expression, got keyword 'if'
But the trouble is: you cannot see these exceptions, even if you handle exceptions, because the syntax errors are not caught if you just put your code in your script; the script fails silently.

If you ask me how I know about those errors, I'll answer later; I'm using my special technique.

The essence of the problem is this: you cannot use "if" in the for loop, you need to use some Boolean condition itself:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for.

I hope this article will make it clear for you.

Now, how I expose those SyntaxError objects? This is the JavaScript technique I found and published on CodeProject in my article JavaScript Calculator, the section "5. Handling Lexical Errors". Read it and you will understand it.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900