Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, AJAX has been around since donkey's years, really. But since you're not familiar with JS, here's a little copy-paste function you could use:</p> <pre><code>function ajax(url,method,data) { var xhr;//ajax object data = data || {};//default ajax request method = method || 'POST'; url = url || 'default/url/ajax'; try {//normal browsers ret = new XMLHttpRequest(); } catch (error) {//older IE browsers, including dead IE6 try { ret= new ActiveXObject('Msxml2.XMLHTTP'); } catch(error) { try { ret= new ActiveXObject('Microsoft.XMLHTTP'); } catch(error) { throw new Error('no Ajax support?'); } } } if (typeof ret !== 'object') {//if fails (almost impossible) throw new Error('No Ajax, FFS'); } ret.open(method, url, true);//open ajax connection ret.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); ret.setRequestHeader('Content-type', 'application/x-www-form-urlencode'); ret.onreadystatechange = function() { if (this.readyState === 4 &amp;&amp; this.status === 200) { var response = this.responseText; //code you want to see executed when the call was successful } }; return ret.send(data); } </code></pre> <p>Usage:</p> <pre><code>ajax('your/ajax/url','POST','id=12'); </code></pre> <p>This will send an ajax request back to the server, with a POST parameter <code>id</code>, value <code>12</code>... play around with that. A few things that can be useful: <a href="http://json.org" rel="noreferrer">JSON</a>, and -though I'm not a big fan- <a href="http://jquery.com" rel="noreferrer">jQuery</a>, it has a ready built-in <code>$.ajax</code> method, just pass an object literal and you're good to go. </p> <p>Feel free to edit this function as you please</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