Is it right to make a request in the request? I need to wait until the first Ajax request returns the values from the database and provides input and buttons, and after that clicking the button I send another Ajax request.
$('#dep-box').on('click', '.show-holidays', function(){ var btn = $(this); var id = btn.parents('form').data('dep-id'); $.ajax({ url : '/settings/get_holidays', method: 'POST', dataType: 'json', data: { id : id }, success: function(data){ var holidaysForm = $('#holidaysFormTpl').render(data); $('.display-table .tbody').append(holidaysForm); initializeDtepicker2(); $('.add-holiday').click(function(){ var btnSaveHol = $(this); $.ajax({ url : '/settings/add_holidays', method : 'POST', data : btnSaveHol.parents('form').serialize(), dataType : 'json', success : function(data){ } }); }); } }); });