I have this JS code (using jQuery Form plugin):
function doLogin(responseText, statusText, xhr, $form) {
var userbox = $(xhr).html();
console.log(userbox);
}
I want to use userbox as a html, so I could cut out some part of it (using find()). What am I doing wrong here?
Full login code:
$('#loginForm').submit(function() {
$(this).ajaxSubmit({
'success': doLogin,
'error': showError
});
function showError() {
$('#loginForm').append('<div class="errorMessage" style="display:none">Błędny login lub hasło.</div>');
$('.errorMessage').fadeToggle();
}
function doLogin(responseText, statusText, xhr, $form) {
var userbox = $(responseText).html();
console.log(userbox);
}
return false;
})
Okay, the problem is solved, and it is – as almost always 🙂 – my mistake.
As David Hedlund mentioned,
responseTextwas the key. Here’s updated code, is anyone needs it: