在发布之前,我已经通读过,但我仍不清楚如何实现这一目标。 我收到一个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() {...});