|
|
|
ขอถาม........ซักนิดครับ ผมอยากให้ คลิกลิงค์ด้านซ้าย แล้วให้มันแสดงผมในด้านขวาเลยครับ |
|
|
|
|
|
|
|
frame
|
|
|
|
|
Date :
2010-11-26 17:32:17 |
By :
monotakari |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
/*** By Weerachai Nukitram ***/
/*** http://www.ThaiCreate.Com ***/
?>
<html>
<head>
<title>ThaiCreate.Com Ajax Tutorial</title>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(ID) {
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 = 'AjaxPHPContent2.php';
var pmeters = "tID="+ID;
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>
</head>
<body Onload="JavaScript:doCallAjax('1');">
<h1>My Content</h1>
<table width="577" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="104" valign="top">
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM content ORDER BY ContentID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<a href="JavaScript:doCallAjax('<?=$objResult["ContentID"];?>');"><?=$objResult["ContentID"]." ".$objResult["Subject"];?></a><br>
<?
}
?>
<?
mysql_close($objConnect);
?>
</td>
<td width="540" valign="top"><span id="mySpan"></span></td>
</tr>
</table>
</body>
</html>
Go to : Ajax Load Content (PHP+MySQL and ASP+Access)
|
|
|
|
|
Date :
2010-11-26 17:36:02 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๆ ครับ
|
|
|
|
|
Date :
2010-11-27 15:37:12 |
By :
genetonique |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|