javascript - dynamically load external JS and write response to a div -


i'm embedding delicious feed page. when add script tags inside div loads before rest of js (at bottom of page). i'd load script specified div dynamically after other js has loaded.

i've tried getscript function, breaks page when use .html():

$('#delicious').html(function(){ $.getscript("http://feeds.delicious.com/v2/js/bayonnebridge?title=my%20delicious%20bookmarks&icon=m&count=5&sort=date&tags&extended&name&showadd");  }); 

i can't seem wrap head around how can print results of file #delicious div.

if want display script in div, shouldn't this, making use of callback function?

$.getscript("http://feeds.delicious.com/v2/js/bayonnebridge?title=my%20delicious%20bookmarks&icon=m&count=5&sort=date&tags&extended&name&showadd",               function(data){                 $('#delicious').html(data);             });  

the result of $.getscript() xmlhttprequest object , seems want response text instead.

also, looks response url you've given attempts write script document, overwriting page content. problem might consider using iframe , setting url it's source.

i seem different behaviour depending on whether script being loaded cross-domain or same domain - i'm not quite sure make of since getscript() supposed work cross-domain.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -