I am trying to override the getJSON
function in jQuery to provide additional params and then call the original getJSON
. I am fairly unfamiliar with JavaScript and have scraped this together from other similar examples. Most of the examples I have seen override the behavior from a function in the jQuery.fn
namespace. Could someone help me by telling me what I am doing wrong?
<html>
<head>
<script type="text/javascript" src="./js/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
(function($){
var _old = $.getJSON;
$.getJSON = function(){
alert("Calling overridden getJSON");
return _old.apply(this,arguments);
};
})(jQuery);
$(document).ready(function() {
try {
$(this).getJSON('ajax/test.json', function(data) {
var items = [];
alert('done');
});
}
catch (err)
{
alert(err.message);
}
});
</script>
</head>
<body>
</body>
</html>