AJAX XMLHttpRequest ﺭﻭﺮﺳ ﺦﺳﺎﭘ


فهرست مطالب

    نمایش فهرست مطالب


ﺭﻭﺮﺳ ﺦﺳﺎﭘ ﯼﺎﻫ ﯽﮔﮋﯾﻭ

responseText

ﺪﯿﻨﮐ ﺖﻓﺎﯾﺭﺩ ﯼﺍ ﻪﺘﺷﺭ ﺕﺭﻮﺻ ﻪﺑ ﺍﺭ ﺦﺳﺎﭘ ﯼﺎﻫ ﻩﺩﺍﺩ

responseXML

ﺪﯿﻨﮐ ﺖﻓﺎﯾﺭﺩ XML ﯼﺎﻫ ﻩﺩﺍﺩ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺦﺳﺎﭘ ﯼﺎﻫ ﻩﺩﺍﺩ


answerText ﯽﮔﮋﯾﻭ

ﮏﯾ ﺕﺭﻮﺻ ﻪﺑ ﺍﺭ ﺭﻭﺮﺳ ﺦﺳﺎﭘ responseText ﯽﮔﮋﯾﻭ

ﻝﺎﺜﻣ

document.getElementById("demo").innerHTML = xhttp.responseText;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<div id="demo">
<h2>The XMLHttpRequest Object</h2>
<button type="button" onclick="loadDoc()">Change Content</button>
</div>

<script>
function loadDoc() {
  const xhttp = new XMLHttpRequest();
  xhttp.onload = function() {
    document.getElementById("demo").innerHTML =
    this.responseText;
  }
  xhttp.open("GET", "ajax_info.txt");
  xhttp.send();
}
</script>

</body>
</html>

answerXML ﯽﮔﮋﯾﻭ

.ﺩﺭﺍﺩ ﯽﻠﺧﺍﺩ XML ﻩﺪﻨﻨﮐ ﻪﯾﺰﺠﺗ ﮏﯾ XMLHttpRequest ﯽﺷ

.ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ XML DOM ﯽﺷ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺭﻭﺮﺳ ﺦﺳﺎﭘ respon

:ﺪﯿﻨﮐ ﻪﯾﺰﺠﺗ XML DOM ﯽﺷ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺦﺳﺎﭘ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﯽﮔﮋﯾﻭ ﻦﯾﺍ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ

ﻝﺎﺜﻣ

:ﺪﯿﻨﮐ ﻪﯾﺰﺠﺗ ﺍﺭ ﺦﺳﺎﭘ ﻭ ﺪﯿﻨﮐ ﺖﺳﺍﻮﺧﺭﺩ ﺍﺭ cd_catalog.xml ﻞﯾﺎﻓ

const xmlDoc = xhttp.responseXML;
const x = xmlDoc.getElementsByTagName("ARTIST");

let txt = "";
for (let i = 0; i < x.length; i++) {
  txt += x[i].childNodes[0].nodeValue + "<br>";
  }
document.getElementById("demo").innerHTML = txt;

xhttp.open("GET", 
 "cd_catalog.xml");
xhttp.send();

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h2>The XMLHttpRequest Object</h2>
<p id="demo"></p>
 
<script>
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
  const xmlDoc = this.responseXML;
  const x = xmlDoc.getElementsByTagName("ARTIST");
  let txt = "";
  for (let i = 0; i < x.length; i++) {
    txt = txt + x[i].childNodes[0].nodeValue + "<br>";
  }
  document.getElementById("demo").innerHTML = txt;
}
xhttp.open("GET", "cd_catalog.xml");
xhttp.send();
</script>

</body>
</html>


ﺭﻭﺮﺳ ﯽﯾﻮﮕﺨﺳﺎﭘ ﯼﺎﻫ ﺵﻭﺭ

getResponseHeader()

ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺭﻭﺮﺳ ﻊﺒﻨﻣ ﺯﺍ ﺍﺭ ﯽﺻﺎﺧ ﺭﺪﻫ ﺕﺎﻋﻼﻃﺍ

getAllResponseHeaders()

ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺭﻭﺮﺳ ﻊﺒﻨﻣ ﺯﺍ ﺍﺭ ﺭﺪﻫ ﺕﺎﻋﻼﻃﺍ ﻡﺎﻤﺗ


.()getAllResponseHeaders ﺪﺘﻣ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺭﻭﺮﺳ ﺦﺳﺎﭘ ﺯﺍ ﺍﺭ ﺭﺪﻫ ﺕﺎﻋﻼﻃﺍ ﻪﻤﻫ getAllResponseH

ﻝﺎﺜﻣ

const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
    document.getElementById("demo").innerHTML =
    this.getAllResponseHeaders();
}
xhttp.open("GET", "ajax_info.txt");
xhttp.send();

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h2>The XMLHttpRequest Object</h2>
<p>The getAllResponseHeaders() function returns all the header information of a resource, like length, server-type, content-type, last-modified, etc:</p>

<p id="demo"></p>

<script>
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
  document.getElementById("demo").innerHTML =
  this.getAllResponseHeaders();
}
xhttp.open("GET", "ajax_info.txt");
xhttp.send();
</script>

</body>
</html>

.()getResponseHeader ﺪﺘﻣ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺭﻭﺮﺳ ﺦﺳﺎﭘ ﺯﺍ ﺍﺭ ﯽﺻﺎﺧ ﺭﺪﻫ ﺕﺎﻋﻼﻃﺍ getResponseHea

ﻝﺎﺜﻣ

const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
    document.getElementById("demo").innerHTML =
    this.getResponseHeader("Last-Modified");
}
xhttp.open("GET", "ajax_info.txt");
xhttp.send();

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h2>The XMLHttpRequest Object</h2>

<p>The getResponseHeader() function is used to return specific header information from a resource, like length, server-type, content-type, last-modified, etc:</p>

<p>Last modified: <span id="demo"></span></p>

<script>
const xhttp=new XMLHttpRequest();
xhttp.onload = function() {
  document.getElementById("demo").innerHTML =
  this.getResponseHeader("Last-Modified");
}
xhttp.open("GET", "ajax_info.txt");
xhttp.send();
</script>

</body>
</html>

تمامی حقوق محفوظ است. © BasicIT.org • 2023-2024