Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Patrick http://www.hunlock.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Synchronous AJAX

// Snippet showing how to use synchronous AJAX

   1  
   2  function getFile(url) {
   3    if (window.XMLHttpRequest) {              
   4      AJAX=new XMLHttpRequest();              
   5    } else {                                  
   6      AJAX=new ActiveXObject("Microsoft.XMLHTTP");
   7    }
   8    if (AJAX) {
   9       AJAX.open("GET", url, false);                             
  10       AJAX.send(null);
  11       return AJAX.responseText;                                         
  12    } else {
  13       return false;
  14    }                                             
  15  }
  16  
  17  var fileFromServer = getFile('http://somedomain.com/somefile.txt');
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS