show_page.php:
<?
session_start();
include("includes/function.php");
$static = mysql_query("SELECT * FROM fb_pages WHERE user_id = '$_SESSION[user_id]' AND page_value = '1' ") or die(mysql_error());
while($stat = mysql_fetch_array($static)) {
$page = $stat['page_name'];
echo json_encode($page);
exit();
}
ob_and_flush();
?>
and js code:
<script type="text/javascript">
$.ajax({
type: "POST",
url: "show_page.php",
dataType: "JSON", //tell jQuery to expect JSON encoded response
success: function(response) {
$('#page').html(response);
}
});
</script>
I like show the result in <div id="page"></div>
.
If run this code, the result is one page, and always one page, but if I delete in show_page.php , exit(); then result is good, show all page, but don't show webpage, I think, then may json. What this problem??