0

In my JSON javascript live pull I have:

    html += "<tr><td width=60 valign=top><a href='"+item.url+"' target='_blank'>"+item.site+"</a></td>";

The += seems to strip out my tr td values So I tried amending it to = which just seems to fail.. I tried setting td as a var and still no luck

Any ideas of a way round this, my js is basic so even if you think its silly your answer could help me greatly..

EDIT

to confuse things things further the = alone works in Firefox but on IE the items are loading hidden in the background.. I don't get why the browsers would perform so differently over the use of one + sign...

6
  • 6
    You don't seem to be closing the <a> Commented Jun 4, 2010 at 15:01
  • How are you trying to use this html value? How do you know those things are being stripped? Commented Jun 4, 2010 at 15:02
  • You should show us some more of your code. What is the value of html before the line you include? What are you doing with it after setting/appending to it? Commented Jun 4, 2010 at 15:24
  • EDIT They are displayed table less in the browser.. and viewing the output both tag are missing Commented Jun 4, 2010 at 15:26
  • When you say "output" do you mean the html source? Or do you mean the rendered content in the browser? Commented Jun 4, 2010 at 15:35

2 Answers 2

3

try:

html += "<tr><td width=60 valign=top><a href='"+item.url+"' target='_blank'>"+item.site+"</a></td></tr>";

Your markup generated is invalid (not closing the anchor tag) so it's possible the browser isn't interpreting the html very well.

Sign up to request clarification or add additional context in comments.

3 Comments

that was just a mistake when rewriting it here haha
You should update your question then as it's misleading. I hope you didn't downvote because of that fact as someone did. You should also consider posting more code than one line as the line in question may not even be the issue at all.
I didn't down vote you, I appreciate the help.. I'm bad at coding but now quite that bad hahah
1

x += y is just a shorthand for x = x + y. If you change it to html = "...", you'd be overwriting anything that already existed in the html variable.

How are your "tr td values" being stripped?

2 Comments

Clobbered... is that a technical term? ;)
Heh, I didn't mean to use it twice in my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.