โดย fa12mkungz » 09/05/2012 2:24 pm
โค้ด: เลือกทั้งหมด
<html>
<head>
<script>
var ajax=null;
if(window.ActiveXObject){
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
ajax =new XMLHttpRequest();
}
function ajaxload(method,URL,displayElementById,sendData){
if(!ajax){
alert("Your browser doesn't support Ajax");
return;
}
ajax.open(method,URL);
ajax.onreadystatechange = function(){
if(ajax.readyState==4 && ajax.status==200){
var ajax_result = ajax.responseText;
var e1 = document.getElementById(displayElementById);
e1.innerHTML = ajax_result;
}
}
ajax.send(sendData);
}
</script>
</head>
<body>
<button onclick = "ajaxLoad('get','http://localhost:8000/GetAllRoom.exe','dv',null)">Data from Server</button>
<div id="dv"> </div>
</body>
</html>
[code]<html>
<head>
<script>
var ajax=null;
if(window.ActiveXObject){
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
ajax =new XMLHttpRequest();
}
function ajaxload(method,URL,displayElementById,sendData){
if(!ajax){
alert("Your browser doesn't support Ajax");
return;
}
ajax.open(method,URL);
ajax.onreadystatechange = function(){
if(ajax.readyState==4 && ajax.status==200){
var ajax_result = ajax.responseText;
var e1 = document.getElementById(displayElementById);
e1.innerHTML = ajax_result;
}
}
ajax.send(sendData);
}
</script>
</head>
<body>
<button onclick = "ajaxLoad('get','http://localhost:8000/GetAllRoom.exe','dv',null)">Data from Server</button>
<div id="dv"> </div>
</body>
</html>[/code]