jQuery Form plugin does not send XMLHttpRequest value

Hi all…

Here we are, again.

This will be a quick post, just for warning in a specific case. When you’re using the jQuery Form plugin by malsup.com you are making an AJAX call, but it does not send some variables that identify a XMLHttpRequest (in my case I’m using the plugin with a upload form).

Continue reading jQuery Form plugin does not send XMLHttpRequest value

Using live function instead of bind with jQuery

Hi all,

Sometimes a big part of an application uses AJAX to get content. When getting new content we get new events, already declared in the webapp. For example:

$(function(){  
    $('a.class1').bind('click', function(){  
        // code here  
    });  
});

If the new content (via AJAX) has a link with class1 class, it won’t call this javascript code, because the click event was previously declared.

So, the solution is use live function instead of bind. When using the live function, the new inserted content will be updated to use the declared javascript events. So it’s better to use live.

$(function(){  
    $('a.class1').live('click', function(){  
        // code here  
    });  
});

Thanks!