I am using $().append() to append some css / divs to a page. In this appended content there is an id that I am trying to use for an $ajax call when user clicks, however it seems to only work if I hardcode the css directly into the page but not if I append… any ideas??
In fact when I append and look into source, there is no div… is this how $().append() works?
MY CODE
$('.out-div').append('<p class="reward"><input type="text" name = "login"/><br/><input type="submit" name="ajax_call" class ="ajax_call"/></form></p>');
AJAX CODE
$(document).ready(function(){
$(".ajax_call").click(function(){
$.ajax({
url: 'http://localhost/places/password/12345/format/jsonp',
dataType: 'jsonp',
type: 'GET',
success: function(){
setCookie('user_id',5,7);
// window.location.reload(true);
}
});
});
});