I'm having trouble passing a variable declared in an $.each() function to Prototype function. I'm receiving the error Uncaught ReferenceError: prices is not defined
Compare.prototype.results = function (answers) {
$.ajax({
type: 'POST',
dataType: 'json',
data: {
answers: answers
},
success: function (data) {
$.each(data, function (index, dataItem) {
var prices = [],
priceData = dataItem.pricing_term,
priceObj = JSON.parse(priceData);
$.each(priceObj, function (term, pricing) {
prices.push(term, pricing);
});
});
Compare.prototype.show(data, prices);
}
});
}
I want to be able to populate the prices variable and pass it to be used with the data that is originally returned from the ajax call. I am new to javascript, if there is a cleaner way to go about writing this please let me know.
$.each.