Using Jquery I need to trigger a ajaxComplete event.
At the moment I’m using this code with no success
$.getJSON(assetUrl, function (data) {
...
$.trigger("ajaxComplete");
With Error:
TypeError: 'undefined' is not a function (evaluating '$.trigger("ajaxComplete")')
Any idea what I’m doing wrong? Thanks
The
ajaxCompletedevent is fired on the DOM, and you will need to call thetriggermethod on a jQuery wrapper element:$(document).trigger(...), for example.There is not static function “trigger” on the
jQueryobject (that’s what the error message is telling you), you might use$.event.trigger– though I fear that’s internal.However, you won’t need to do it manually;
getJSONdoes trigger the event itself. For aborting a running ajax request, see theabortmethod of XHR objects.