好的,请考虑以下几点:
function(){
function getRate(source, scope) {
var dateValue = $("Date", source).text() || "";
if (!dateValue) {
return null;
}
var d = new Date();
var dailyPrice = $("DailyPrice", source).text() || "";
var weeklyPrice = $("WeeklyPrice", source).text() || "";
var monthlyPrice = $("MonthlyPrice", source).text() || "";
var isAvailable = $("IsAvailable", source).text() === "1";
var minimumStay = Number($("MinimumStay", source).text());
return {
date: new Date(dateValue),
dailyPrice: dailyPrice,
weeklyPrice: weeklyPrice,
monthlyPrice: monthlyPrice,
reserved: !isAvailable,
minimumStay: minimumStay
};
}
return {
getRates: function(xml){
return getRates(xml);
},
getAllRates: function(source, scope){
return new getRate();
},
};
}
我如何从这个函数之外获得dailyPrice 我已经尝试了以下但它返回null
var getitall = getAllRates();
当我通过调试器运行它时,它会到达函数,但总是将值返回为 null。为什么?