Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX won't POST to URL
    primarykey
    data
    text
    <p>Im trying to build a simple AJAX script that uses a form to send parameters to the Tumblr API.</p> <p>This is the current code:</p> <pre><code>&lt;body&gt; &lt;script type="text/javascript"&gt; function ajaxFunction() { var email = document.getElementById("email").value; var password = document.getElementById("password").value; var title = document.getElementById("title").value; var body = document.getElementById("body").value; var str = "&amp;email=" + email + "&amp;password=" + password + "&amp;title=" + title + "&amp;body=" + body; //document.write(str); var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { document.getElementById("suc").value.innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST","http://www.tumblr.com/api/write?generator=TumblWave&amp;type=regular",true); xmlhttp.send(str); } &lt;/script&gt; &lt;form id="myForm"&gt; Name: &lt;input type="text" id="email" /&gt; Password: &lt;input type="password" id="password" /&gt; Title: &lt;input type="text" id="title" /&gt; Body: &lt;input type="text" id="body" /&gt; &lt;input type="submit" onclick="ajaxFunction();" /&gt; &lt;div id="suc"&gt;&lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Sorry for the mess. </p> <p>Somehow, the XMLHttpRequest doesn't seem to pull through, since nothing ever enters Tumblr. However, when I remove the comments for "document.write(str)" it seems like everything is being fetched as it's supposed to from the forms and printed with the right commands.</p> <p>You might notice on the URL on xmlhttp.open that I've already included two static parameters: the generator name and the type of post that should be sent to the Tumblr API.</p> <p>I made this after a model on w3schools.com with only few modifications. Any help appreciated :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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