Set relevant context to done()
callback, e.g using bind()
and btw, prefer to use closest()
:
$(document).on('click', '#file-submit', function () {
$.ajax({
url: url,
type: 'POST',
cache: false,
data: formData,
processData: false,
contentType: false
}).done(function (data, status, jqxhr) {
//now 'this' refers to clicked element
var nextId = $(this).closest('.tab-pane').next().attr("id");
alert(nextId);
}.bind(this)).fail(function (data, status, jqxhr) {
console.log("error");
});
})
solved jquery ajax submit callback get this closet [closed]