In the console.log, I can see that this.id is undefined after the Ajax call. I would still like to use the id of .home after that. I know I can again still perform $('.home').attr('id') in the .done section but that would be repeating the same code again. Is there a better/more efficient way of calling this.id (the id of .home) inside .done? I have placed the JavaScript file at the bottom of the <body> tag.
JQuery
$(".home").submit(function(e) {
e.preventDefault();
e.stopPropagation();
var sendData = {
//Some data
};
var url = "/home" + this.id;
$.ajax({
url: url,
type: "POST",
contentType: "application/json",
data: JSON.stringify(sendData)
}).done(function(result){
//This shows undefined.
console.log(this.id)
})
});