0
Hello, good morning, good morning!! staff need help!
I have the following list created in html, it is not complete, just for you to understand.
<ul class="lista">
<li>Datetime:</li>
<li>Velocidade:</li>
<li>$ Inicial:</li>
<li>$ Atual: </li>
<li>$ Financ: </li>
<li>% Neil: </li>
and I have in JS this( I took in a tutorial, and I think this is what I need
var numsList = [];
$.ajax( 'Input.txt', {
dataType: 'text',
success: function(response){
//response é o conteudo do Input.txt
var lines = response.split('\n'); //quebra o arquivo em linhas,
for(var i in lines){
var row = lines[i];
var nums = row.split(','); //quebra a linha em valores separdos por virgula
for(var j in nums){
var num = parseInt(nums[j]); //converte o valor para int
if( !isNaN(num) ) //basicamente verifica se é um numero
numsList.push(num); //adiciona o item no array
}
}
console.log(numsList);
}
});
I also have a txt(Input.txt) file with some information separated by comma.
What I want is to feed the list with the txt file information, but put them in the correct position
for example
I have the first item on the list Datatime: and inside it I want to put the first item of the txt file
but I don’t know how to call JS in HTML.
From now on Thank you.
It would be much simpler to use a file in the format JSON, then you wouldn’t worry about picking commas, breaking in lines, etc... If you use Json, from the line
success
down, nothing that is there would be needed.– LeAndrade
right! and you know how to put it on the list ?
– Lila Guimarães Reis
The problem Lila that I think you are new in the area right?! Would you know adapt to your code there? Here by the site there is no way to do Ajax.
– LeAndrade