So I was looking on some SO questions and the jQuery area to try to use the similar feature in PHP using explode which will just explode a string given into it's pieces from a type of substring.
This is the code I used:
var users = // AJAX CALL TO GET USERS
var usersArr = users.split();
I looked at the w3 tutorial for splitting strings and this was the JavaScript type, and even that didn't work.
Error message:
index.js:45 Uncaught TypeError: users.split is not a function
asynchronous!..split('')(empty string). But make sure that your ajax request has returned from server (common pit fall)var users = $.ajax();thenuserswill be a deferred object, not a string, hence the error you get. You should use the callback of the AJAX request. Alsosplit()requires a parameter to break the string by.