javascript - Click trigger on anchor that is loaded by ajax -


i trying use ajax trigger on anchor dynamically generated ajax.

this tried no success , no errors:

        $('.exceldl').live('click', function(e){             $.ajax({                 url: 'exceldl.php',                 data: $('#myform').serialize(),                  type: 'post',                  success: function(data){                     $('.xldl').html(data);                     attach = $('.xldl a').attr("href");                      $('.xldl a').trigger('click');                 }             });         }); 

i believe because inserting new elements dom using ajax trigger not working, why tried using live. not sure how proceed , solve problem.

i appreciate suggestions.

many in advance!

use "on" instead of "live"

    $(document).on('click','.exceldl',function(e){         $.ajax({             url: 'exceldl.php',             data: $('#myform').serialize(),              type: 'post',              success: function(data){                 $('.xldl').html(data);                 attach = $('.xldl a').attr("href");                  $('.xldl a').trigger('click');             }         });     }); 

jquery on documentation : http://api.jquery.com/on/

jquery live deprecated after 1.7


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -