Skip to main content

Bug Tracker

Side navigation

#4448 closed bug (invalid)

Opened March 30, 2009 07:11AM UTC

Closed March 30, 2009 10:51PM UTC

Last modified March 15, 2012 02:30PM UTC

$.getJSON() and append() link tags <a href>demo</a> sometimes is wrong

Reported by: opengloves Owned by:
Priority: minor Milestone: 1.4
Component: data Version: 1.3.2
Keywords: json and appden link tag Cc:
Blocked by: Blocking:

Good day!

I use jquery-1.3.2.min.js. I want append some link tags in a div, but something is wrong, against my expect.

some links are right, like this:

<a href="">demo</a>

but some are:

<a href=""/>demo

and these wrong tags was different is Firefox and IE 7.

For example such function:

json data:[{"linkKey":"http:://","linkValue":"demo"}]


<div id="site"></div>

<div><a id="home">show</a></div>





$("#site").append("<span><a href="+json[i].linkKey+">"+json[i].linkValue+"</a></span>");});});});

To fix this, I have to change the function like this:



n = i+1;

$("site").append("<span><a id=id"+n+">"+json[i].linkValue+"</a></span>");



but this isn't suitable, I think.

Attachments (0)
Change History (4)

Changed March 30, 2009 10:51PM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

Your href attribute is not quoted in the HTML you generate, so it is being mis-parsed in some cases. Nothing jQuery can do about invalid HTML...

Changed March 31, 2009 07:43AM UTC by opengloves comment:2

Thank you for your response.

I quoted href attribute like this:

$("#site").append("<span><a href=\\""+json[i].linkKey+"\\">"+json[i].linkValue+"</a></span>");

and it works right. thank you very much.

Changed March 31, 2009 07:54AM UTC by opengloves comment:3


Firefox 3 works right,but in IE 7 still have some wrong link tags.

Changed March 31, 2009 08:04AM UTC by opengloves comment:4

I thought this is sth. wrong in others libs. thanks again.