I am dynamically creating elements inside a loop
m += '<input type="text" id="deadline_input_' + data[i].data.sequence + '" value="' + (data[i].deadline == "-" ? '' : data[i].deadline) + '" data-seq="' + data[i].data.sequence + '" class="hasDatepicker deadline_input" dateFormat="DD-MM-YYYY" style="display:none;" />';
m += '<span id="deadline_text_' + data[i].data.sequence + '">' + data[i].deadline + '</span>';
$('#results_projects').append(m);
but then when I use
$("#deadline_input_" + $(this).data("seq")).show();
$("#deadline_text_" + $(this).data("seq")).hide();
inside an ajax call, they are not changing. I know the ajax call is succeeding because I have added a console.log("success")
inside my success which shows in the console
my full ajax call is:
$.ajax({
url : '/section/projects',
type: "GET",
data: {
"action": "update_deadline",
"sequence": $(this).data("seq"),
"deadline": $(this).val(),
},
success: function(data) {
console.log("success");
$("#deadline_input_" + $(this).data("seq")).hide();
$("#deadline_text_" + $(this).data("seq")).show();
},
error: function(err) {
alert("There was an error updateing the Project");
}
});