hi,
i want to display output line by line using jquery.i tried many times but it not works..pls help me..
Html Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#sub').click(function(){
$('#msg').html("<center><img src='http://46.16.168.75/saranya/images/9%20(1).gif' alt='LOADING...' width='20' height='20'/>Loading........</center>");
$.ajax({
type: "POST",
url: "ping1.php",
data: $("#form1").serialize(),
success: function(data) {
$('#msg').html(data);
alert(data);
}
});
return false;
});
});
</script>
<div id="tag">
<form id="form1" method="" action="">
<input name="ip" type="text"/>
<!--<button id="sub">submit</button>-->
<input type="button" name="submit" id="sub" value="submit"/>
</form>
</div>
<div id="msg"></div
Php:
<?php
$ip=$_POST["ip"];
header('Content-Encoding: none;');
set_time_limit(0);
$handle = popen("ping -c 4 $ip", "r");
if (ob_get_level() == 0) ob_start();
while(!feof($handle)) {
$buffer = fread($handle,1024);
$buffer = trim(htmlspecialchars($buffer));
echo $buffer . "<br />";
echo str_pad('', 4096);
ob_flush();
flush();
}
pclose($handle);
ob_end_flush();
?>
if i submit the form using php it will show the output in line by line..but i use jquery to submit the form means it will display the output but not in line by line.