Note that there are some explanatory texts on larger screens.

plurals
  1. POconverting XMLHTTPRequest into $ajax
    text
    copied!<p>I am fetching Google in a gadget using this code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Browser&lt;/title&gt; &lt;/head&gt; &lt;body onload= "getListCollection()" style="width:900px; height:900px;" &gt; &lt;div id="listAttributes" style="width:400px; height:400px;" &gt;&lt;/div&gt; &lt;script&gt; function getListCollection() { var url = "https://www.google.co.uk" xmlhttp = new XMLHttpRequest(); xmlhttp.open('GET',url,true, 'user', 'password'); xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4); { document.getElementById("listAttributes").innerHTML = xmlhttp.responseText } } xmlhttp.send(null); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I wonder how can I do the same thing using $ajax?</p> <p>I looked at different examples but I don't know how they gonna fit in this situation. Or if you can post some nice $ajax tutorials please.</p> <p>When I change it to this, it doesn't work:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Browser&lt;/title&gt; &lt;/head&gt; &lt;body onload= "getListCollection()" style="width:900px; height:900px;" &gt; &lt;div id="listAttributes" style="width:400px; height:400px;" &gt;&lt;/div&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"&gt; $.ajax({ url : 'https://www.google.co.uk', type : 'GET', success : function(data){ $('#listAttributes').html(data); } }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Nothing comes up on the page.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload