|
|
|
ช่วยดู script ให้หน่อยคะ ie8 ไม่รองรับ..หาวิธีแก้ไม่ได้ เป็นมือใหม่หัดขับ script อ่ะคะ |
|
|
|
|
|
|
|
Code (JavaScript)
<script language="javascript" type="text/javascript">
var PersonID = "<%getPersonID%>"
var BTH = document.getElementById('Branch')
var url ='BranchDesc.aspx'
var Branchs = document.getElementById('ddlBranchID')
Branchs.onchange = Bonclick;
window.onload = setDisplay;
var Asy = new Asychronous();
function setDisplay(){
BTH.style.display = 'block;
Bonclick()
}
function Bonclick(){
// Ajax Section
var myRandom=parseInt(Math.random()*99999999);
var p = "?mode=Create&PersonID=" + PersonID + "&BranchID=" + Branchs.options[Branchs.selectedIndex].value + "&rnd=" + myRandom
var request = new HTTPRequest();
if (request){
request.open('GET',url+p,true)
request.onreadystatechange = function(){
if (request.readyState==4){
ReadXMLDoc();
}
}
request.send(null)
}
// Ajax Section
}
function ReadXMLDoc(){
var DocUrl = '../XMLDocument/Document_' + PersonID + '.xml'
var req = new HTTPRequest();
if (req){
req.open('GET',DocUrl,true)
req.onreadystatechange = function(){
if (req.readyState==4){
DocumentRender(req)
}
}
req.send(null)
}
}
function DocumentRender(req){
var xmlhttp = new HTTPRequest();
var myRandom=parseInt(Math.random()*99999999);
var p = "?mode=Delete&PersonID=" + PersonID + "&rnd=" + myRandom
if (xmlhttp){
xmlhttp.open('GET',url+p,true)
xmlhttp.send(null)
}
if (req){
var Doc = req.responseXML;
document.getElementById('Name').innerHTML =getData(Doc,'Name')
document.getElementById('PermitName').innerHTML = getData(Doc,'PermitName')
document.getElementById('Address').innerHTML = getData(Doc,'Address')
}
}
function getData(Doc,name){
//return Doc.getElementsByTagName(name)[0].text
var retName = "";
if(Doc.getElementsByTagName(name)[0].childNodes[0] != "undefined"){
retName= Doc.getElementsByTagName(name)[0].childNodes[0].nodeValue
}
return retName;
}
</script>
ขอบคุณมากนะคะ
Tag : ASP, JavaScript, Ajax, VB.NET
|
|
|
|
|
|
Date :
2012-01-24 09:16:34 |
By :
mupee |
View :
1714 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนไปใช้ jQuery แทนครับ จะได้ลดปัญหานี้ สำหรับ Ajax แล้ว jQuery เขียนสั้น ๆ ครับ
Code (JavaScript)
<html>
<head>
<title>ThaiCreate.Com jQuery Tutorials</title>
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn1").click(function(){
$.ajax({ url: "webpage.php" })
.success(function(result) { $("#div1").html(result); })
.error(function() { $("#div1").html("error"); })
.complete(function() { $("#div1").after("Ajax load finished"); });
});
});
</script>
</head>
<body>
<div id="div1"></div>
<input type="button" id="btn1" value="Load">
</body>
</html>
Go to : jQuery Ajax : jQuery and Ajax
|
|
|
|
|
Date :
2012-01-24 09:50:25 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|