|
 |
|
รบกวนสอบถามนิดนึงครับ จากบทความ Ajax: Real Time - Display data Real-time |
|
 |
|
|
 |
 |
|
ดูตัวอย่างนี้ครับ ใช้ jQuery เขียนง่ายกกว่าครับ
jQuery Load แสดงข้อมูล Real-Time / Ajax
|
 |
 |
 |
 |
Date :
2013-08-06 21:49:18 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ พี่ครับ แต่ผมจะทำให้มันเพิ่ม ลบ แก้ไข ในหน้าเดียวเลยครับ ผมใช้ AJAX ธรรมดาครับ ทำได้ครับ แต่พอแบบ มีหลายตารางมากขึ้นแล้ว ผมไม่รู้จะใส่ค่ายังไงครับ
|
 |
 |
 |
 |
Date :
2013-08-06 21:54:13 |
By :
คนโง่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้ายากมากก็ใช้การเขียนแบบปกติครับ อย่าทำให้ Ajax มาทำให้ชีวิตยุ่งยากครับ
|
 |
 |
 |
 |
Date :
2013-08-07 06:12:54 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทำเเล้วคับ หน้า getdata คิวรี่ผ่าน แต่พอมาหน้า index มันไม่ขึ้นคับ
นี้โค้ดที่ผมทำคับ
getdata_index.php
Code (PHP)
<?
include ("conne.php");
$strSQL = "select * from oder where status = 'รอจัดของ' order by number_so ASC";
$objQuery = mysql_query($strSQL) or die (mysql_error());
$intNumField = mysql_num_fields($objQuery);
$resultArray = array();
while($obResult = mysql_fetch_array($objQuery))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
echo json_encode($resultArray);
?>
index.php
Code (PHP)
<?
include ("../right_user.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>STORE:KOOL-Inventory</title>
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
font-size: 16px;
font-weight: bold;
}
.style2 {font-size: 14px}
-->
</style>
<script src="jquery-latest.js"></script>
<script>
function getDataFromDb()
{
$.ajax({
url: "getdata_index.php" ,
type: "POST",
data: ''
})
.success(function(result) {
var obj = jQuery.parseJSON(result);
if(obj != '')
{
//$("#myTable tbody tr:not(:first-child)").remove();
$("#myBody").empty();
$.each(obj, function(key, val) {
var tr = "<tr>";
tr = tr + "<td>" + val["number_so"] + "</td>";
tr = tr + "<td>" + val["name_customer"] + "</td>";
tr = tr + "</tr>";
$('#myTable > tbody:last').append(tr);
});
}
});
}
setInterval(getDataFromDb, 10000); // 1000 = 1 second
</script>
<body>
<div id="templatemo_wrapper">
<div id="templatmeo_header">
<?
include ("menu.php");
?>
<!-- end of templatemo_menu -->
</div>
<!-- end of header -->
<div id="templatemo_main">
<div class="content_box">
<div id="home">
<table width="361" border="0" align="center">
<!-- head table -->
<thead>
<tr>
<td width="274" bgcolor="#A3D615"><div align="center" class="style1">ใบจัดของ</div></td>
<td width="77" bgcolor="#A3D615"><div align="center"></div></td>
</tr>
</thead>
<!-- body dynamic rows -->
<tbody id="myBody"></tbody>
</table>
</div>
<div class="content_box_content">
<div class="cleaner h30"></div>
<div class="cleaner"></div>
</div> <!-- end of content box content -->
</div> <!-- end of a content box -->
<div id="aboutus"></div>
<!-- end of a content box -->
<!-- end of a content box -->
<!-- end of a content box -->
<div class="content_box content_box_last">
<div id="contactus"></div>
<!-- end of content box content -->
</div>
<!-- end of a content box -->
</div> <!-- end of main -->
<div id="templatemo_footer">
<a href="http://server/checkstock" target="_parent">Back to Home</a> </div>
<!-- end of templatemo_footer -->
</div> <!-- end of wrapper -->
</body>
</html>
รบกวนดูไห้หน่อยนะคับ
|
 |
 |
 |
 |
Date :
2013-08-07 10:01:02 |
By :
เอ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|