Testcase for jQuery Ticket 7418
jsonp with jsonpCallback not removing script tags
by jitter
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<button>Click Repeatedly</button>
<p><br />If the reported issue existed, clicking the button repeatedly would cause an exception.</p>
<p>Also when clicking the button below outputs something different from 0 to the console the issue exists</p><br />
<button>Check number of left over script tags</button>
JavaScript
//note the "no wrap (head)" setting on the left.
//now this really is a globally defined function
function handleJsonp(data) {
console.log(data);
}
//because of no wrap we need to wrap the code ourself in a ready-handler-construct
$(function() {
$('button:first').bind("click", function() {
$.ajax({
url: 'http://jsfiddle.net/echo/jsonp/',
dataType: 'jsonp',
jsonpCallback: 'handleJsonp',
data: {
a: "b"
}
});
});
//conveniently check number of left over script tags
$('button:last').bind("click", function() {
console.log($("head script[src^='http://jsfiddle.net/echo/jsonp/']").length);
});
});