|
 |
|
สอบถามเรื่อง การส่งค่าGET จาก PHP ไปที่ AJAX ค่ะ รบกวนผู้รู้ด้วยค่ะ |
|
 |
|
|
 |
 |
|
Code (PHP)
<script type="text/javascript">
$(function(){
setInterval(function(){ // เขียนฟังก์ชัน javascript ให้ทำงานทุก ๆ 30 วินาที
// 1 วินาที่ เท่า 1000
// คำสั่งที่ต้องการให้ทำงาน ทุก ๆ 3 วินาที
var get_date=document.getElementById('date1').value;
var getData=$.ajax({ // ใช้ ajax ด้วย jQuery ดึงข้อมูลจากฐานข้อมูล
url:"que.php",
data: {date:''+get_date},
type: 'get',
async:false,
success:function(getData){
$("div#showData").html(getData); // ส่วนที่ 3 นำข้อมูลมาแสดง
}
}).responseText;
},1000);
});
</script>
|
 |
 |
 |
 |
Date :
2013-09-23 15:01:58 |
By :
jackkichan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้ไหมหว่า 
Code (Java)
data: "{'date':'"+ $("#date1").val()+"'}",
,
|
ประวัติการแก้ไข 2013-09-23 15:03:54 2013-09-23 15:04:35
 |
 |
 |
 |
Date :
2013-09-23 15:02:24 |
By :
anotherdie |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<div id="showData"></div>
<input type="datetime" name="date1" id="date1" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function(){
setInterval(function(){ // เขียนฟังก์ชัน javascript ให้ทำงานทุก ๆ 30 วินาที
// 1 วินาที่ เท่า 1000
// คำสั่งที่ต้องการให้ทำงาน ทุก ๆ 3 วินาที
var getData=$.ajax({ // ใช้ ajax ด้วย jQuery ดึงข้อมูลจากฐานข้อมูล
url:"check.php",
data:"date="+$('#date1').val(),
async:false,
cache:false,
type:"GET",
success:function(getData){
$("div#showData").html(getData); // ส่วนที่ 3 นำข้อมูลมาแสดง
}
}).responseText;
},1000);
});
</script>
check.php
Code (PHP)
<?
echo $_GET['date'];
?>
|
 |
 |
 |
 |
Date :
2013-09-23 15:18:10 |
By :
Ex-[S]i[L]e[N]t |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|