|
 |
|
Ajax กับการทำงานบน firefox ที่ไม่สามารถใช้งานได้ โดยมี2ไฟล์ ในการส่งค่า และคืนค่ามายัง Area |
|
 |
|
|
 |
 |
|
ผมมี File อยู 2 ไฟล์นะครับ
ไฟล์แรกชื่อ testsendajax.php
ไฟล์2ชื่อ getarea.php
//-----Code for testsendajax.php ------//
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
return xmlHttp;
}
function loadselect(areaf,url,protid)
{
var idst=protid;
var rnd=Math.random();
var sendid="";
sendid+=url+"rnd="+rnd+"&id="+idst;
createXMLHttpRequest()
xmlHttp.onreadystatechange=function statechange()
{
if(xmlHttp.readyState==4 )
{
var x=document.getElementById(areaf);
x.innerHTML=xmlHttp.responseText;
}
else
{
var x=document.getElementById(areaf);
x.innerHTML="Wait....";
}
}
xmlHttp.open("GET",sendid,true);
xmlHttp.Send(null);
//listtxt_selset(id,listname,urllist);
}
</script>
</head>
<body>
<p>Goto Ajax</p>
<form id="form1" name="form1" method="post" action="" >
<select name="select" id="select" onchange="return loadselect('aread','getarea.php?',this.value)">
<option value="1">data</option>
<option value="2">text</option>
<option value="3">found</option>
</select>
</form>
<p><div id="aread"> </div></p>
</body>
</html>
//----------------- End testsendajax.php --------//
ส่วนไฟล์ที่ 2 getarea.php เป็นไฟล์ที่ ประมวลผลของ ค่าที่ได้รับ แล้วกลับไปส่งยัง testsendajax.php ใน <div id='aread'>
//---Code for getarea.php ----// ไม่ได้มีอะไรมากครับ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
test ID Ajax = <? echo $_GET['id'];?>
</body>
</html>
ผลที่ได้ใน IE รันได้ปกติครับ แต่ใน firefox ไม่สามารถที่จะรันได้
ใครรู้วิธีแก้ไข รบกวนช่วยทีนะครับ
//------------------------ ขอบคุณครับ -----------------------//
Tag : PHP, JavaScript, Ajax

|
|
 |
 |
 |
 |
Date :
2011-12-13 10:42:40 |
By :
bluesix |
View :
820 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
55555555555555555555555555555555555555555555555555555555555555555+
งมไปงมมาสุดท้ายก็ได้สักทีครับ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
var objRequest = createRequestObject();
function createRequestObject() {
var objTemp = false;
if (window.XMLHttpRequest) {
objTemp = new XMLHttpRequest();
} else {
objTemp = new ActiveXObject("Microsoft.XMLHTTP");
}
return objTemp;
}
function getData(areaf,url,protid) {
if (objRequest) {
var idst=protid;
var rnd=Math.random();
var sendid="";
sendid+=url+"rnd="+rnd+"&id="+idst;
objRequest.open("GET",sendid);
objRequest.onreadystatechange=function handleResponse()
{
var objDiv = document.getElementById(areaf);
if (objRequest.readyState == 4 && objRequest.status == 200)
{
objDiv.innerHTML = objRequest.responseText;
}
}
objRequest.send(null);
}
}
</script>
</head>
<body>
<body>
<p>Goto Ajax</p>
<form id="form1" name="form1" method="post" action="" >
<select name="select" id="select" onchange="return getData('aread','getarea.php?',this.value)">
<option value="1">data</option>
<option value="2">text</option>
<option value="3">found</option>
</select>
</form>
<p><div id="aread"> </div></p>
</body>
</body>
</html>
แหล่งที่มา เอามาดัดแปลงเอาเองนะครับ ท่านที่จะใช้
ขอบคุณท่าน คินมากครับ ผมหาตั้งนาน
http://www.webthaidd.com/webboard/index.php/topic,98.0.html
|
 |
 |
 |
 |
Date :
2011-12-13 12:28:18 |
By :
bluesix |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|