ช่วยดูให้หน่อยครับ Ajax ใช้ได้กับfirefoxแต่ ieไม่ได้ครับ

aj_PostMember.php


<?
header("Content-Type: texe/plain; charset=TIS620");
$name=$_POST["name"];
$address=$_POST["address"];
$email=$_POST["email"];

$status="";

$DBServer="localhost";
$DBName="mydb";
$DBUsername="root";
$DBPassword="1234";

$SQL="insert into members(member_name,member_address,member_email) values ('$name','$address','$email')";

$Link=mysql_connect($DBServer,$DBUsername,$DBPassword);
@mysql_select_db($DBName) or  $status = "ไม่สามารถเข้าถึงข้อมูลได้";
if($Result = mysql_query($SQL)){
    $status="บันทึกข้อมูลเรียบร้อยแล้ว";
}else{
    $status="มีข้อผิดพลาดเกิดขึ้น ไม่สามารถบันทึกข้อมูลได้";
}
mysql_close($Link);

echo $status;
?>


aj-PostMember.php


<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>ตัวอย่างการส่ง Request แบบ Post</title>
<style type="text/css">
#info {background: pink;}
</style>


<script type="text/javascript" src="Prototype/prototype-1.6.0.2.js"></script>

<script type="text/javascript">
//------------------------------------------------------------------------------------------

function startRequest(){
var pForm = document.forms[0];
new Ajax.Request(pForm.action,{method: "POST",parameters: $("memberform").serialize(true),onComplete:saveResult});
}

function saveResult(result){
    $("info").innerHTML=result.responseText;
}
</script>
</head>

<body>
<form id="memberform" action="aj_PostMember.php" onsubmit="startRequest(); return false">
<h2>ป้อนข้อมูลสมาชิก</h2>
<table>
<tr><td>ชื่อสมาชิก : </td><td><input type="text" id="name" name="name" /></td></tr>
<tr><td>ที่อยู่ : </td><td><input type="text" id="address" name="address" /></td></tr>
<tr><td>อีเมลล์ : </td><td><input type="text" id="email" name="email" /></td></tr>
</table>
<p><input type="submit" value="บันทึกข้อมูล" id="btsubmit" /></p>
</form>
<div id="info"></div>
</body>
</html>

ใน IE8 <div id="info"></div> ไม่แสดงครับ แต่ข้อมูลลงDBปกติครับ มีerrorดังนี้
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; MASN)
Timestamp: Thu, 25 Mar 2010 11:29:03 UTC


Message: Could not complete the operation due to error c00ce56e.
Line: 1361
Char: 7
Code: 0
URI: http://localhost/...prototype-1.6.0.2.js


Message: Could not complete the operation due to error c00ce56e.
Line: 1361
Char: 7
Code: 0
URI: http://localhost/...prototype-1.6.0.2.js

แต่ในFirefox ทำงานได้ปกติครับ ทำยังไง IEถึงจะทำงานได้ครับ


เป็นเพราะ prototypeหรือเปล่าครับ.....!
ขอบคุณมากๆครับ กำลังศึกษาajaxครับ....มือใหม่ครับ
25 มี.ค. 2553 1 2,904

ถ้าลง db ได้ ก็แสดงว่ามีค่าส่งไป ปัญหาน่าจะอยู่ที่ค่าตอบกลับ

ลองกำหนด header ของไฟล์ที่รับค่าจาก ajax ให้ถูกต้อง โดยลองกำหนดให้เป็น text/html

ลองกำหนดให้เพจทั้งหมดเป็น UTF-8

สุดท้ายลองตรวจสอบค่า return กลับ
#1
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^