<html> <head> <title>ThaiCreate.Com Ajax Tutorial</title> </head> <script language="JavaScript"> var HttPRequest = false; function doCallAjax(url) { 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; } HttPRequest.open('POST',url,false); HttPRequest.send(null); document.getElementById("mySpan").innerHTML = HttPRequest.responseText; } </script> <body> <span id="mySpan"></span> <input name="btnButton" id="btnButton" type="button" value="Click" onClick="JavaScript:doCallAjax('hello.php');"> </body> </html>
<?php /*** By Weerachai Nukitram ***/ /*** http://www.ThaiCreate.Com ***/ for($i=1;$i<=5;$i++) { echo "Hello ThaiCreate.Com <br>"; } ?>
<% '*** By Weerachai Nukitram ***' '*** http://www.ThaiCreate.Com ***' Dim i For i = 1 To 5 Response.write("Hello ThaiCreate.Com <br>") Next %>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท