The getJSON function does not remove the scripts added to head when
using a callback (for jsonp). This of course means that you get a
build up of markup if you're using the getJSON function (with
callback) to poll a resource.

Someone called Tom had noticed this before, but the discussion was not
resolved. I would have replied to this thread but there didn't seem to
be an option to post to the group, only to the individuals involved in
the discussion.

http://groups.google.com/group/jquery-en/browse_thread/thread/5de2eeeb835711a6/c375846e20dec5bd?lnk=gst&q=getjson+remove+scripts

John, who replied to Tom, was wrong in that the jQuery code has a
condition that prevents head.removeChild( script ) being reached if
using jsonp (i.e. if the jsonp variable is set).

It looks like this is by design, presumably because there's no way of
knowing when the callback has finished its work.

Can someone please confirm this or provide further details?

Many thanks.

P.S. As a temporary work-around, I've added the following to the end
of my callback function, which removes the last script tag added to
the head when it's finished its work.

$("head script:last-child").remove();

Reply via email to