Ok, so the problem I am having is that the jquery get() I am using does not use the variable I want it to. Here is the code and I will go into a deeper explanation.
jQuery(document).ready(function() {
$.ajax({
type: "GET",
url: "XTEST.xml",
dataType: "xml",
success: function(xml) {
console.log(xml);
$(xml).find('Chart').each(function(){
chType = $(this).find('chType').text();
chTitle = $(this).find('chTitle').text();
chSubtitle = $(this).find('chSubtitle').text();
yAxisTitle = $(this).find('yAxisTitle').text();
csv = $(this).find('csv').text();
});
$(xml).find('columns').each(function(){
countArray[i] = 0;
cNum = parseInt($(this).find('cNum').text());
cNumArray.push(cNum);
value = $(this).find('value').text();
valueArray.push(value);
vName = $(this).find('vName').text();
vNameArray.push(vName);
i++;
});
},
error: function(){
$('.XTEST').text('Failed to get feed');
}
});
// JQuery function to process the csv data
$.get(csv, function(data) {
// Split the lines
var lines = data.split('\n');
In the get(), I am attempting to give it a variable by the name of 'csv'. The intent is that the csv file name will come from a separate XML file. Although chType, chTitle, chSubtitle, etc. all work how I want them to, the 'csv' variable I created when searching through the 'Chart' section in the XML is not. The csv in the get() is shown as undeclared. Upon further investigation, it seems the get() wants to use a global variable. If you create a global variable named 'csv', it will use it. It does not appear to be a scope issue since I can use variables with data from the XML within and without the get(). It appears to be a trait of the get() line itself. Is there any solution to this, or perhaps I am missing something entirely?