jQuery Ajax GET

jQuery Ajax GET

Hello,

I've got a jQuery and Ajax script which loads and parse a CSV file with papaparse. This works great thanks to help from this forum.

I've found one problem though on one product page I'm using it which I can't seem to get to work.

I've got a select box which you choose between a couple of options and after that the script chooses the right csv file (productCSVname). The first time I choose from this select box it works fine. But if I change the select box which chooses the csv file it dosen't change in the ajax. So the second time it's like it runs the function but skips to GET the new file. Anyone knows why this happens?

Here's a snippet from the ajax GET part.

$. ajax({
type: 'GET',
cache: false,
url: templateUrl + productCSVname + '.csv?q='+ Math. random(),
error : function () {
console. log( 'Function ended on 404');
},
success : function ( data) {
var data = Papa. parse( data). data. map( function( a) {
return a. map( function( v) {
return + v // convert to numbers
})
})
var heights = data. map( function( line) {
return line[ 0]
})

Thank you!

Jon