<?php /*** By Weerachai Nukitram ***/ /*** http://www.ThaiCreate.Com ***/ ?> <html> <head> <title>ThaiCreate.Com Ajax Tutorial</title> </head> <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 = 'Ajax2.php'; var pmeters = 'mySort='+Sort; 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> <body Onload="bodyOnload();"> <h1>ใช้ Ajax แล้วแสดงภาษาไทยไม่ได้...</h1> <form name="frmMain" action="" method="post"> <script language="JavaScript"> function bodyOnload() { doCallAjax('CustomerID') setTimeout("doLoop();",2000); } function doLoop() { bodyOnload(); } </script> <span id="mySpan"></span> </body> </html>
<table width="600" border="1"> <tr> <th width="91"> <div align="center"><a href="JavaScript:doCallAjax('CustomerID')">ID ลูกค้า</a></div></th> <th width="98"> <div align="center"><a href="JavaScript:doCallAjax('Name')">ชื่อลูกค้า</a> </div></th> <th width="198"> <div align="center"><a href="JavaScript:doCallAjax('Email')">อีเมล</a> </div></th> <th width="97"> <div align="center"><a href="JavaScript:doCallAjax('CountryCode')">รหัสประเทศ</a> </div></th> <th width="59"> <div align="center"><a href="JavaScript:doCallAjax('Budget')">Budget</a> </div></th> <th width="71"> <div align="center"><a href="JavaScript:doCallAjax('Used')">Used</a> </div></th> </tr> </table>
<? header("content-type: application/x-javascript; charset=TIS-620"); ?> <table width="600" border="1"> <tr> <th width="91"> <div align="center"><a href="JavaScript:doCallAjax('CustomerID')">ID ลูกค้า</a></div></th> <th width="98"> <div align="center"><a href="JavaScript:doCallAjax('Name')">ชื่อลูกค้า</a> </div></th> <th width="198"> <div align="center"><a href="JavaScript:doCallAjax('Email')">อีเมล</a> </div></th> <th width="97"> <div align="center"><a href="JavaScript:doCallAjax('CountryCode')">รหัสประเทศ</a> </div></th> <th width="59"> <div align="center"><a href="JavaScript:doCallAjax('Budget')">Budget</a> </div></th> <th width="71"> <div align="center"><a href="JavaScript:doCallAjax('Used')">Used</a> </div></th> </tr> </table>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง