Hello I’m coding a searching system via Ajax abit different one and I have a problem, is it possible to break data fetch through ajax and do foreach for each line in javascript?
Here I send the user’s search query to a php file which gives back results from database for that query..
$.post("rpc.php", {queryString: ""+inputString+""}, function(data) {
$('#suggestions').html(data); // Fill the suggestions div
});
so data coming from php file is stored inside data variable as a set but line by line,like example..
Google helps us
Facebook is a social network
Stackoverflow is the best
Im on twitter
but
$('#suggestions').html(data);
will directly put all the things inside data to suggestions html element..
I want to know is it possible to break things inside data to lines and do foreach for each line…
Split the
databy<br />, and then iterate over the resulting lines array: