php - Ajax responseText doesn't contain all of the output -


i started learning basic ajax. not using jquery ajax yet. having problem couldn't resolve after lots of searrching.

my php file is-

$sql = "select * posts"; $result = mysqli_query($con,$sql) or die ('error: ' . mysqli_error($con)); while($feeditem = mysqli_fetch_array($result)) {     echo $feeditem['user']." "; }  echo "dd"; 

and file i'm calling has js script-

xmlhttp = new xmlhttprequest(); xmlhttp.onreadystatechange = function()  {     if (xmlhttp.readystate==4 && xmlhttp.status==200)   {         alert(xmlhttp.responsetext);     } } xmlhttp.open("get","loader.php", true); xmlhttp.send(); 

now, if run php file alone, prints---

user1 user2 user3 dd

but if run other file, alert contains "dd". doesn't alert me user1 user2...

why doesn't inside loop included in responsetext?

your code works me, i've tested it. use console see raw response coming server. looks little strange, run php web browser or cli? congrats not using jquery ajax! watch xmlhttprequest api see can in standard way.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -