0

I've been experimenting with Ajast and it's very useful for getting remote URL sources etc. In the below example it bypasses same-domain-policy and gets "Hello World !", but I cannot recreate this when I change it to google.com.

<html>
  <head>
    <script type="text/javascript" src="http://ajast.org/ajast/ajast.js"></script>
    <script id="TestScript" Language="javascript">
      function test()
      {
        var xmlhttp = new AJAST.JsHttpRequest();
        xmlhttp.onreadystatechange = function()
        {
          if (xmlhttp.readyState==4) // 4 = "loaded"
          {
            if (xmlhttp.status == 200)
              document.write(xmlhttp.responseText);
            else
              alert('ERROR: ' + xmlhttp.status + ' -> ' + xmlhttp.statusText);
          }
        }
        xmlhttp.open("GET", 'http://riffelspot.com/ajast/ajast_full.php', false);
        xmlhttp.send();
      }
    </script>
  </head>
  <body onload="test();">Please wait...</body>
</html>
</code>

My problem occurs when I change the get url to google.com, can anyone help me? I want JavaScript to fetch the source of a page.

Marcel Korpel
  • 21,536
  • 6
  • 60
  • 80
Ben
  • 1

2 Answers2

2

Read the documentation.

AJAST can only be used to send a request to a compatible server-side script.
Basically, it's a non-standard form of JSONP.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 2
    Indeed. It is not a magic key that somehow allows you to avoid the deliberate security restrictions of cross-origin requests. – bobince Nov 04 '10 at 15:15
0

I thought that dynamicly loading the script into the DOM would bypass this security feature, like the quote suggests

"The main advantage of AJAST is its ability to make requests to foreign hosts (cross domain) which a standard AJAX request cannot do using a technique known as 'the script tag hack'. "

Where would I be able to find documentation as i dont want to use a JSONP proxy, I would like to request the webpage without signing.

ben
  • 1
  • You should add this as a comment to SLaks' anwer, he will not be notified of this. But to answer your question: you'll have to use a server-side script to do that. “AJAST leverages a technique that dynamically inserts – Marcel Korpel Nov 04 '10 at 15:38