var rogue = {};
rogue.process = function processRogue(){
if(rogue.isLoginMember($('#name').val(),$('#pass').val()))
{
//user is in xml, go on...
}
else{
messageBox.display('Who says','YOU SHALL NOT PASS.');
}
};
rogue.isLoginMember = function isLoginMember(name, pass){
$.ajax({
url: 'xml/members.xml',
type: 'GET',
dataType: 'xml',
success: function(returnedXMLResponse){
var count=0;
$(returnedXMLResponse).find('user').each(function() {
if($(this).find('name').text() == name)
{
if($(this).find('pass').text() == pass)
{
return true;
}
}
count++;
});
}
});
return false;
};
我不明白为什么当用户或xml中找不到用户时,processRogue()中的else总是会运行。有谁看到了什么事?