Not even sure if this is the right way to title the question. I know I\'m making my AJAX calls all wrong... here\'s what I\'m doing right now (I\'m using ASP.NET MVC backend
First of all if you want AJAX call to return the data you are planning to use in your scripts (and by use I mean something more complicated then displaying that data in a div), you should probably return JSON data instead of HTML from your server. JSON is actually a JS object so it can be used in JS the moment it is received.
So if you return the data i.e.
{id: 1, status: 'ok'}
You can use something like this to use that data.
$.ajax({
url: "your/script/url",
type: "POST",
data: {login : 'foo', pass: 'bar'}, // whatever the data is
dataType: "json",
success: function(data){
if (data.status === 'ok') {
console.log('success');
} else {
console.log('error');
}
}
});