在發佈之前,我已經通讀過,但我仍不清楚如何實現這一目標。 我收到一個xml文件並設置了一些變量,我如何訪問ajax成功之外的所有變量以用於其他函數?
$.ajax({
type: "POST",
url: getProductList,
data: reqProductXML,
dataType: "xml",
contentType: "text/xml; charset=\"utf-8\"",
success: function (data) {
$(xml).find('product').each(function() {
var productID = $(this).find('id').text();
var productName = $(this).find('name').text();
var productCurrency = $(this).find('currency').text();
var productDescription = $(this).find('description');
var sipAccess = $(this).find('sipAccess');
var skypeAccess = $(this).find('skypeAccess');
var localAccess = $(this).find('localAccess');
var rechargeable = $(this).find('rechargeable').text();
$('#urProductSelect').append("<option value='" + productID + "'>" + productName + "</option>");
});
}
}); //End ajax
// I need to use the variable out here....
$('#urProductSelect').change(function() {...});