I would like to send the class of an element to a function. Basically, I need to tell showAjaxLoader() that it should show the loading icon for the element being clicked!
jQuery(function($) {
var showAjaxLoader = function(selector) {
$(selector).empty().html('<img src="loading.gif" />');
};
$(".add")
.bind("ajax:beforeSend", function(event, data, status, xhr) {
var class = this.class;
showAjaxLoader(class);
});
});
classis a reserved word in Javascript, so you can’t use it as a variable name. It’s not available as a property of an element: you need to use theclassNameproperty instead.