Javascript call php and get a response cross-domain without AJAX

If you google "how to find if a cross domain file exists from javascript", the hamster chorus at stackoverflow will tell you it can't be done without AJAX, and even then you are lucky if it works.

But if you load a PHP script from HTML, the php script will run, and if the php script has a callback, you can run a javascript function as the callback, when the php script has finished.

If you want to call the script twice you use you set the .src of the HTML script line to the same thing (or something else), and it gets called again.

For trailer park async, use setTimeout to call the php several times. The rest of your program can execute while you are waiting for the server.

This works cross-domain, so you can call a script on another website.
The PHP can tell you if a file exists, return a JSON dataset, or all of the things you aren't supposed to do cross-domain.

<div id="backupDiv"></div>  
 function addJavascript(jsname, pos, id) {  //
   var th = document.getElementsByTagName(pos)[0];  
   var s = document.createElement('script');  
   s.setAttribute('type', 'text/javascript');  
   s.setAttribute('src', jsname);  
   s.setAttribute("id", id);  
 function db_PHPresponse(prefix) {  
   var delay, message = "Processing",backupDivE=document.getElementById('backupDiv');  
   backupDivE.innertext = message;   
   for (delay = 0; delay < 6000; delay += 1000) {  
    setTimeout(function() {  
      var str, dv;  
      if (backupDivE.innertext === message) {  
       try {  
         dv = document.getElementById('delscript');  
         if (dv) {  
         str = '' + prefix + db_username() + '.php';  
         addJavascript(str, 'body', "delscript");  
       } catch (e) {  
    }, delay);  
And the PHP 
 echo 'db_callback(' . json_encode(array('I could not forbear getting up to the top of a little mountain, and looking out to sea, in hopes of seeing a ship : then fancy that, at a vast distance, I spied a sail, please myself with the hopes of it, and, after looking steadily, till I was almost blind, lose it quite, and sit down and weep like a child, and thus increase my misery by my folly.')) . ')' ;