Step 1 - Create a PHP page that reads the string in the database, saves it to a variable (eg,
$datas
) and returns that string.
Note: The "return" I am talking about is NOT done with
return $datas
, but with
echo $datas
, because this way the "return" of the page can be received by the requester (In this case AJAX).
Step 2 - Create a Javascript function (Preferably using Jquery) that makes a request to the PHP page you created. When you mount the AJAX request, you will have to pass a callback function that will be responsible for handling the request response (The answer PHP returns with echo $datas
).
Step 3 - In the callback function you created in step 2, you will eventually have a string (eg datas
) with dates in raw format. Then you will use the split
function (which is applicable to strings) to break the string and save the result to a vector. The split
function separates the string into several pieces, so this separation is controlled by the parameter you pass ( Learn more about to split here ).
Ex. 1:
var datas = "O rato roeu a roupa"
var vetor = datas.split(" "); // Separa o conteúdo de ***datas*** usando ***espaço***
// vetor = {"O", "rato", "roeu", "a", "roupa"}
Ex. 2:
var datas = "O rato roeu a roupa"
var vetor = datas.split("a"); // Separa o conteúdo de ***datas*** usando ***a***
// vetor = {"O r", "to roeu ", " roupa"}
I do not know your level of knowledge and, of the things I put up, I do not know what you know. So I could have been very wordy and have written unnecessary things (which would be good, because that would be a sign that you already know) or I may have been very superficial and did not explain everything very well. Anyway, if the second hypothesis is true, I advise you to make a rejoinder listing all the points you did not understand and / or do not know how to do. This will make it easier for the people to help you.
DoeSangue
HelpNext