sas523
دوشنبه 29 تیر 1388, 23:59 عصر
سلام دوستان من یه فایل از جنس php نوشتم که تولید ِ یه فایل ِ xml میکنه ؛
فایل xml ام به این صورته که اسمشم گذاشتم file.php ؛
کد:
<?php
header("content-type : text/xml ; charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
echo "<book>
<c>
<n>Hello User</n>
</c>
<c>
<n>wellcom</n>
</c>
</book>";
?>
حالا میخوام ازین فایل به صورت ajax استفاده کنم تا نمایش داده بشه
کدhtml ام به این صورته ؛
<script language="javascript">
var xmlHttp = null;
var xmlObj;
function Create(){
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}else {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
}
return xmlHttp ;
}
function update (){
if (xmlHttp.readyState == 4 ){
xmlObj = xmlHttp.responseXML ;
alert(xmlObj.xml) ;
}
}
function Ok(){
Create();
xmlHttp.open('GET' , 'FILE.php', true );
xmlHttp.onreadystatechange = update ;
xmlHttp.send(null);
}
OK();
</script>
]
اما ازم ارور میگیره ممنون میشم کمک کنید.:لبخندساده:
فایل xml ام به این صورته که اسمشم گذاشتم file.php ؛
کد:
<?php
header("content-type : text/xml ; charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
echo "<book>
<c>
<n>Hello User</n>
</c>
<c>
<n>wellcom</n>
</c>
</book>";
?>
حالا میخوام ازین فایل به صورت ajax استفاده کنم تا نمایش داده بشه
کدhtml ام به این صورته ؛
<script language="javascript">
var xmlHttp = null;
var xmlObj;
function Create(){
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}else {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
}
return xmlHttp ;
}
function update (){
if (xmlHttp.readyState == 4 ){
xmlObj = xmlHttp.responseXML ;
alert(xmlObj.xml) ;
}
}
function Ok(){
Create();
xmlHttp.open('GET' , 'FILE.php', true );
xmlHttp.onreadystatechange = update ;
xmlHttp.send(null);
}
OK();
</script>
]
اما ازم ارور میگیره ممنون میشم کمک کنید.:لبخندساده: