在执行用户登录时,如果登录成功,我希望在某个div中显示一条消息。但是,如果登录失败,则会在另一个div中显示另一条消息。是否可以确定Ajax的'returnData‘的内容并相应地更新相应的div?例如:
$(document).ready(function() {
$('.submitForm').ajaxForm({
success: function(returnData) {
if (returnData == '...') { // (or: len(returnData) == ... whatever)
$('#someDiv').html(returnData);
} else {
$('#otherDiv').html(returnData);
}
}
});
});发布于 2012-12-26 11:23:27
是的,这当然是可能的。您使用的是伪代码:
if returnData == '...'
$('#someDiv').html(returnData);
else
$('#otherDiv').html(returnData);但它实际上会是什么并不遥远:
if(returnData == '...') // note the parentheses
$('#someDiv').html(returnData);
else
$('#otherDiv').html(returnData);发布于 2012-12-26 11:23:21
当然。当然,返回数据必须支持传递登录请求的成功或失败。在这种假设下,您的代码看起来非常正确。你试过了吗?
https://stackoverflow.com/questions/14035655
复制相似问题