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);
You can use split() and pop():
var lastValue = csv_Data.split(",").pop(); // "blue"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With