|
|
|
สอบถามการนำค่าในฐานข้อมูลมาแสดงในตารางเมื่อมีการเลือกListmenu |
|
|
|
|
|
|
|
ลองอ่านบทเรียนเกี่ยวกับ ajax ดูครับ
|
|
|
|
|
Date :
2010-08-29 13:03:48 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Sort) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'get2.php';
var pmeters = 'mySort='+document.getElementById("id_room2").value;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
</script>
ในกรณีนี้เราส่งค่าไปค่าเดียวคือ var pmeters = 'mySort='+document.getElementById("id_room2").value;
ถ้าเราจะส่งสองค่าไปพร้อมกันละคับ
|
|
|
|
|
Date :
2010-08-29 13:10:28 |
By :
piag3026 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ar pmeters = 'mySort='+document.getElementById("id_room2").value+'¶m2='+document.getElementById("param2").value;
|
|
|
|
|
Date :
2010-08-29 13:35:50 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|