-1
我有这个JS代码(使用jQuery表格插件):使用jQueryForm XHR为HTML
function doLogin(responseText, statusText, xhr, $form) {
var userbox = $(xhr).html();
console.log(userbox);
}
我想用userbox
为HTML,这样我就可以切出(使用find()
)它的某些部分。我在这里做错了什么?
完整的登录代码:
$('#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;
})
'$(responseText的)。html的()''返回时null''$(XHR)的.html()'返回代码(这是不符合工作' find()'虽然)。 – 2012-07-30 08:51:04
如何调用'doLogin'?从服务器返回什么? '$(xhr).html()'产生什么代码?你在传递给'.find'的选择器是什么? – 2012-07-30 08:56:43
我用完整的登录代码更新了我的问题。我错了,'$(responseText).html()'和'$(xhr).html()'返回null,'$(xhr)'单独返回整个页面源代码。 – 2012-07-30 08:58:52