Search code examples
jqueryajaxjquery-load

jQuery - do something after an element is loaded via ajax, but not in the ajax function


I'm trying to watch for an element to load on the page from an ajax call. I don't have access to the jquery that's making the ajax call. So, when some new html is loaded onto the page, I'd like to apply some changes to it.

I'm currently trying to use the .load() function:

$( '.autosuggest_keyword' ).load( 
    function()
    { 
        $( this ).val( 'load test' );
    }
);

Which isn't doing anything. I even tried making that a live binding, which doesn't really make sense, but I thought I'd give it a try.

The selector is correct.

Any ideas?


Solution

  • I was able to get access to the original ajax call, so this question is moot now. I'm leaving it up for others to find, however, in case one of these answers helps them.