After hours of searching and testing I finally have decided to post a question.
I need to be able to make something like this to work with a function.
var myCSV = [1,3,5,6];
Currently, I can grab the CSV from the database as that is how it is stored, myColumn = 1,3,5,6. I can get it to pass as an AJAX success response but it seems to want to add quotes. I then tried to add JSON encode to my PHP side of things and JSON Parse to the success call but still cannot get the function to work. The end goal is to select checkboxes based off the csv value.
This works
var FilterArray = [1,3,5,6]; // Manually added these numbers as is for testing
$('#myForm').find('.checks').each(function () {
$(this).prop("checked", ($.inArray(parseInt($(this).val()), FilterArray ) != -1));
});
After trying to much to get my AJAX success response to work in the FilterArray, I decided to just pass it to an input value and work with it. However, cannot figure out how to not treat it as a string when I pass it to the function. Here is what I have tried.
In my getCSV.php I have at the end this
json_encode($foundCSV);
In my AJAX Success
var FilterArray = JSON.parse(response);
I have also tried it without the json_encode and just sending it to an input value which does not add quotes.
So in summary, how can I take a csv e.g. 1,3,5,6 stored value and pass it to a function that works as shown above?