Zseven Zseven - 2 months ago 7
jQuery Question

jquery in ajax.load loader showing every "mouseover"

i hope subject is clear, i try to explain better my problem.

I have a menu and i'd like to load submenu just on mouseover on parent li of menu.
It works, but every time i go on parent, i see loader.
I'd like that loader to be visible just on first mouseover.
You can see it here:

Thanks in advance.

This is the code:

function pageLoad() {

var SessionLingua = '<%= Session("Lingua") %>';

$(".LinkPadreBoxMenu").mouseover(function (event) {
event.preventDefault(); //preventing button's default behavior
var IDCategoriaGenitore = $(this).next("#LblIDCategoria").html();

$('.A_' + IDCategoriaGenitore).show();

$(".SottoCategorieAjax_" + IDCategoriaGenitore).load('/' + SessionLingua + '/ajax_categorie.aspx', { 'IDCategoriaGenitore': IDCategoriaGenitore }, function () {
$('.A_' + IDCategoriaGenitore).hide();


Answer Source

Use localStorage to store some value on ajax call. Now next time when you hover, check whether you have localstorage value. By this, you can condition you loading image.