This question already has an answer here:
I have a textarea in my html, I want to send each lines via ajax to my request page and get the response but I don't know how to.
Example -
textarea lines -
Akib
Richard
Parkar
[Button Check]
it should return one-by-one line, like Akib - 90 Scores then Richard - 50 scores Parkar 40 scores
without refreshing
I only have a code that send single data and get single response
there is the single response getting code
<script>
function GetResult() {
var xmlhttp = new XMLHttpRequest();
var str = $('textarea#combo').val();
//var decCount = $('#invalid-count').val();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if ( this.responseText.indexOf("Dec") > -1 ) {
decCount=$('#invalid-count').val()+1;
var output = '<div class="result-div">'+this.responseText+'</div>';
$("#result-dec").append(output);
alert(decCount);
document.getElementById("invalid-count").innerHTML=decCount;
}
}
};
xmlhttp.open("GET", "test2.php?combo=" + str, true);
xmlhttp.send();
}
</script>```
</div>