i'm trying fetch data using jquery ajax method. here code:
$('body').on('click','.showslots', function() { var screen_id = $(this).attr('id'); //alert(screen_id); $.ajax({ url:base_url+'admin/movies/getscreenslots', type:'post', data: {screen_id:screen_id}, success: function(result) { result = $.parsejson(result); //$('.screenlist1,.screenlist12').empty(); $.each(result, function( key, element ) { $('<tr class="screenlist1"><td><input required name="slotname" type="text" placeholder="enter slot"><input name="screen_id1" required type="hidden" value="'+element.screen_id+'" class="screen_ids1"></td><td><input required name="moviename" type="text" placeholder="movie name"></td><td><input required name="rate" type="text" placeholder="rate"></td></tr>').appendto($(this).closest('table')); }); } }); });
data getting db. , jquery 'each' function working well. 'appendto' function not working. tried in many browser. same problem in all. please help. thank you.
this
not refer think does.
you should find table element outside ajax call, , save variable:
$('body').on('click','.showslots', function() { var screen_id = $(this).attr('id'); var table = $(this).closest('table'); $.ajax({ url:base_url+'admin/movies/getscreenslots', type:'post', data: {screen_id:screen_id}, success: function(result){ result = $.parsejson(result); $.each(result, function( key, element ){ $('...your html...').appendto(table); }); } }); });
Comments
Post a Comment