View Full Version : XMLHttpRequest
  
dr_csharp
پنج شنبه 29 آذر 1386, 11:51 صبح
چطور میتونم با استفاده از شیع xmlHttpRequest محتویات یک صفحه رو در صفحه ی خودم نشون بدم ؟
dr_csharp
پنج شنبه 29 آذر 1386, 12:29 عصر
راه حل پیدا شد ..گفتم شما هم استفاده کنید :
<html>
<head>
<script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {
    document.getElementById('T1').innerHTML=xmlhttp.re sponseText;
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}
</script>
</head>
<body onload="loadXMLDoc('test_xmlhttp.txt')">
<div id="T1" style="border:1px solid black;height:40;width:300"></div><br />
<button onclick="loadXMLDoc('Test.aspx')">Click</button>
</body>
</html>
 
در نمونه مثال فوق ، محتویات صفحه ی Test.aspx بدون پست بک در T1 ، div لود میشه
rezamizbani
شنبه 01 دی 1386, 11:57 صبح
در نمونه مثال فوق ، محتویات صفحه ی Test.aspx بدون پست بک در T1 ، div لود میشه
 
در واقع اجاکس از همین تکنولوژی استفاده می کنه عزیزم !!!
peyman1987
شنبه 01 دی 1386, 12:48 عصر
بهتره بگیم ایجکس همینه. چیز زیاد عجیبی هم نیست.
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.