我有以下的javascript:jQuery的 - 变量的作用域问题
$.getJSON('/calculate_quote/' + moulding_1_id, function(data) {
moulding_1_cost = data.moulding.cost;
moulding_1_width = data.moulding.width;
});
cost_of_moulding = ((2 * (width + (2 * moulding_1_width)) + 2 * (height + (2 * moulding_1_width)))/1000) * moulding_1_cost;
$('#item_total').html(cost_of_moulding);
的问题是,这两个变量moulding_1_cost
和moulding_1_width
是的getJSON呼叫的不确定之外。如何在getJSON调用之外使这两个变量可用?
或这^ ^更好 – slobodan 2010-11-30 14:47:35