Link to home
Start Free TrialLog in
Avatar of Alex Lord
Alex Lord

asked on

displaying js array by append to div container by id

Getting Error

Uncaught TypeError: Cannot read property 'ownerDocument' of undefined
    at Function.fa.contains (jquery-2.2.4.min.js:2)
    at ca (jquery-2.2.4.min.js:3)
    at ua (jquery-2.2.4.min.js:3)
    at n.fn.init.append (jquery-2.2.4.min.js:3)
    at Object.<anonymous> (contact-profile.js:104)
    at i (jquery-2.2.4.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-2.2.4.min.js:2)
    at z (jquery-2.2.4.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery-2.2.4.min.js:4)

Open in new window


when trying to append a container with data.

socialIcons.push($(['<a href= "' + demo1.infomation.URL[i] + '" target="_blank" title="'+ demo1.infomation.TYPE_NAME +'">','<img  width="30" height="30" src="images/icons/fullcontact/"'+ demo1.infomation.TYPE_ID[i] +'.png" />'
            ,'</a>' ]));
            console.log(socialIcons); // socialicons

$("#social-icons").append(socialIcons);

Open in new window


the following array outputs this to console.

n.fn.init(3) ["<a href= "http://www.pinterest.com//" tar…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"pinterest.png" />", "</a>"]
1
:
n.fn.init(3) ["<a href= "http://vimeo.com/user9875399" target="_b…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"vimeo.png" />", "</a>"]
2
:
n.fn.init(3) ["<a href= "https://gravatar.com/" target="_bl…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"gravatar.png" />", "</a>"]
3
:
n.fn.init(3) ["<a href= "https://twitter.com/" target="_…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"twitter.png" />", "</a>"]
4
:
n.fn.init(3) ["<a href= "https://www.linkedin.com/in/" t…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"linkedin.png" />", "</a>"]
5
:
n.fn.init(3) ["<a href= "http://klout.com/" target="_bla…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"klout.png" />", "</a>"]
6
:
n.fn.init(3) ["<a href= "https://www.facebook.com/" tar…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"facebook.png" />", "</a>"]
7
:
n.fn.init(3) ["<a href= "https://www.flickr.com/people/"…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"flickr.png" />", "</a>"]
8
:
n.fn.init(3) ["<a href= "https://foursquare.com/user/" tar…itter,LinkedIn,Klout,Facebook,Flickr,Foursquare">", "<img  width="30" height="30" src="images/icons/fullcontact/"foursquare.png" />", "</a>"]
length
:
9

Open in new window


Im trying to output this array to html this is within the ajax success outputs any tips ?
Avatar of Alex Lord
Alex Lord

ASKER

$('#header-icons').html(socialIcons);

Open in new window


Just to add i have also tried incase of dom issue and same result.
Update

So i updated the line as so -

socialIcons.push(['<a href= "' + demo1.infomation.URL[i] + '" target="_blank" title="'+ demo1.infomation.TYPE_NAME +'">','<img  width="30" height="30" src="images/icons/fullcontact/"'+ demo1.infomation.TYPE_ID[i] +'.png" />'
            ,'</a>' ]);
            console.log(socialIcons); // socialicons

Open in new window


the console output is correct but now a new error trying to append to html.

Uncaught TypeError: a.replace is not a function
    at Function.htmlPrefilter (jquery-2.2.4.min.js:3)
    at ca (jquery-2.2.4.min.js:3)
    at ua (jquery-2.2.4.min.js:3)
    at n.fn.init.append (jquery-2.2.4.min.js:3)
    at Object.<anonymous> (contact-profile.js:108)
    at i (jquery-2.2.4.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-2.2.4.min.js:2)
    at z (jquery-2.2.4.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery-2.2.4.min.js:4)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for correcting me