Replacing anonymous functions with named function (in jQuery)

旧街凉风 提交于 2019-12-04 19:04:30

You are assigning the functions to the handlers incorrectly, try this:

jQuery().ready(function ($) {
    $('[id="errorMessages"]').ajaxStart(fs);
    $('[id="errorMessages"]').ajaxError(fe);
});

Note that passing the name of the function without brackets means you are giving the reference of that function which should be used when the event occurs.

Your current code will call the function when the event is attached (hence why you're getting 'e' is undefined) and assign the result of the function to the event handler.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!