# AJAX xhr status when local?

**URL:** <https://forum.kirupa.com/t/ajax-xhr-status-when-local/279358>\
**Category:** web dev\
**Created:** [January 13, 2009, 10:22pm UTC](https://forum.kirupa.com/t/ajax-xhr-status-when-local/279358 "2009-01-13T22:22:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GrndMasterFlash](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@GrndMasterFlash](https://forum.kirupa.com/u/GrndMasterFlash)\
**Post date:** [January 13, 2009, 10:22pm UTC](https://forum.kirupa.com/t/ajax-xhr-status-when-local/279358/1 "2009-01-13T22:22:04Z")

</div>

i am using a little AJAX to load text files onto a page for this xml/javascript blog engine im making, every thing is fine, but i want the engine to operate regardless if its on line or in a local folder.

the one hang up im hitting is when it’s local there is no load status sent back from the server and as you can see by my code since there is not status the 200 (which mean OK it’s loaded) never gets sent back

```auto
function do_xhr() {
  // Step 1: Setup xhr_obj
  if (window.XMLHttpRequest) {
    xhr_obj = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    xhr_obj = new ActiveXObject("Microsoft.XMLHTTP");
  }

  // Step 2: Setup asyn. handler.
  xhr_obj.onreadystatechange = handle_xhr_obj;

  //Step 3: Open request URL
  xhr_obj.open("GET", "pages/blog/wacva_new.txt", true);

  //Step 4: execute
  xhr_obj.send(null);
}

function handle_xhr_obj() {
 // alert("In handle_xhr_obj, readystate = " + xhr_obj.readyState);

  if (xhr_obj.readyState == 4) {
    alert("XHR complete");
  if (xhr_obj.status == 200){
      document.write("XHR successful. Message = " + xhr_obj.responseText);
   }
  }
}

```

how can i get it so that if the blog is ran local not from a server everything is still ligit and my file loads, when i comment out the if(xhr\_obj.status == 200) part it will load, but then i think that would cause error when it’s loading from a server

any ideas
