Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As you already mentioned in your question, <a href="https://github.com/sstephenson/prototype/blob/master/src/prototype/ajax/request.js#L179" rel="nofollow"><strong>prototype averts PUT, DELETE,... requests</strong></a> by default. <a href="https://prototype.lighthouseapp.com/projects/8886/tickets/289-allow-put-delete-and-other-http-methods-on-ajax-requests" rel="nofollow">Some people</a> (including me) think that this is stupid behavour, but since the developer doenst seem to care about that, we have to do it by editing the request-function itself (without touching our dist of prototype.js!):</p> <pre><code>Ajax.Request.prototype.request = function(url) { this.url = url; this.method = this.options.method; var params = Object.isString(this.options.parameters) ? this.options.parameters : Object.toQueryString(this.options.parameters); // NOTE: THE MISSING PART WAS HERE if (params &amp;&amp; this.method === 'get') { // when GET, append parameters to URL this.url += (this.url.include('?') ? '&amp;' : '?') + params; } this.parameters = params.toQueryParams(); try { var response = new Ajax.Response(this); if (this.options.onCreate) this.options.onCreate(response); Ajax.Responders.dispatch('onCreate', this, response); this.transport.open(this.method.toUpperCase(), this.url, this.options.asynchronous); if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); this.transport.onreadystatechange = this.onStateChange.bind(this); this.setRequestHeaders(); this.body = this.method == 'post' ? (this.options.postBody || params) : null; this.transport.send(this.body); /* Force Firefox to handle ready state 4 for synchronous requests */ if (!this.options.asynchronous &amp;&amp; this.transport.overrideMimeType) this.onStateChange(); } catch (e) { this.dispatchException(e); } }; </code></pre> <p>Run this code after Prototype got inited. Now this:</p> <pre><code>new Ajax.Request('42', {method:'PUT'}); </code></pre> <p>Will cause an actual <strong>HTTP PUT</strong> Request (<a href="http://jsfiddle.net/BvvbR/1/" rel="nofollow">see a jsFiddle</a>).</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