Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Below which using raw xml rather than using prototype works.</p> <p>When I use prototype ajax call, 405 method not allowed would return, not sure why.</p> <pre><code>&lt;script type="text/javascript"&gt; function simplePut() { var xmlHttp = new XMLHttpRequest(); var invId = document.getElementById("invIdField").value; var invName = document.getElementById("invNameField").value; //put info into JSON format var jsonInput = JSON.stringify(new Array(invId, invName)); var url = "resources/inventory/" + invId; xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4 &amp;&amp; xmlHttp.status == 200) { //out = xmlHttp.responseText; document.getElementById('simple').innerHTML = xmlHttp.responseText; } } xmlHttp.open("put", url, true); //xmlHttp.open("put", "resources/inventory/1", true); //xmlHttp.setRequestHeader("Content-Type", "text/plain"); xmlHttp.setRequestHeader("Content-Type", "application/json"); xmlHttp.send(jsonInput); }//end protoAjaxPut &lt;/script&gt; ...html body &lt;body&gt; &lt;h1&gt;Inventory page&lt;/h1&gt; &lt;table border="1" cellspacing="1" cellpadding="5"&gt; &lt;th&gt;id&lt;/th&gt; &lt;th&gt;amount&lt;/th&gt; &lt;c:forEach items="${inventoryList}" var="inv" &gt; &lt;tr&gt; &lt;td&gt;${inv.id}&lt;/td&gt; &lt;td&gt;&lt;a href="" onclick="ajaxGet(${inv.id}); return false;"&gt;${inv.amount}&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/c:forEach&gt; &lt;/table&gt; &lt;hr /&gt; &lt;h3&gt;REST&lt;/h3&gt; &lt;form method="post" action=""&gt; Inventory ID: &lt;input type="test" id="invIdField" readonly /&gt;&lt;br /&gt; Inventory Name: &lt;input type="text" id="invNameField" /&gt;&lt;br /&gt; &lt;input type="button" value="insert POST form" onclick="protoAjaxPost()" /&gt;&lt;br /&gt; &lt;!-- &lt;input type="button" value="update PUT" onclick="protoAjaxPut()" /&gt;&lt;br /&gt; --&gt; &lt;div id="putResponseText"&gt;&lt;/div&gt; &lt;/form&gt; &lt;button onclick="protoAjaxPut()"&gt;update PUT&lt;/button&gt;&lt;br /&gt; &lt;button onclick="simplePut()"&gt;call SIMPLE PUT&lt;/button&gt;&lt;br /&gt; &lt;button onclick="ajaxDelete()"&gt;HTTP DELETE&lt;/button&gt;&lt;br /&gt; &lt;div id="simple"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre>
 

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