Say I have a CSV string:
red,yellow,green,blue
How would I programatically select blue from the string using jQuery?
The data is returned via an AJAX request from a PHP script rendering a CSV file.
var csv_Data;
$.ajax({
type: 'GET',
url: 'server.php',
async: false,
data: null,
success: function(text) {
csv_Data = text;
}
});
console.log(csv_Data);
No jQuery, plain JavaScript:
I strongly recommend against making synchronous calls.
Reference:
string.splitUpdate: If you really only want to get the last value, you can use
lastIndexOf[docs] andsubstr[docs]: