Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere can I find decent jQuery ajax headings setting documentation?
    text
    copied!<p>Instead of using the beforeSend method of setting the request headers, I decided I wanted to look into using the headers setting option of a jQuery $.ajax() call. Naturally, I went to this page here, <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">http://api.jquery.com/jQuery.ajax/</a>, but the documentation is scarce and I can't find any way to set multiple headers and the format for doing so on that page, or anywhere else.</p> <p>@tahir: Then why is this not working?</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Multiple DnD Uploader&lt;/title&gt; &lt;link rel="stylesheet" href="style.css" /&gt; &lt;script type = "text/javascript" src = "../music/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#drop').change(function(event){ files = event.target.files; $('#drop').css('display', 'none'); for(var i = 0, len = files.length; i &lt; len; i++) { alert(files[i].fileName); $.ajax({ type: "POST", url: "uploader.php", contentType: "multipart/form-data", headers: { "X-File-Name" : ""+files[i].fileName, "X-File-Size" : ""+files[i].fileSize }, data: 'hi', success: function(data){ $('#info').append('Success: ' + data + '&lt;br /&gt;'); },error: function(data){ $('#info').append('Error: ' + data + '&lt;br /&gt;'); } }); } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="drop"&gt; &lt;h1&gt;Drop files here&lt;/h1&gt; &lt;p&gt;To add them as attachments&lt;/p&gt; &lt;input type="file" multiple="true" id="filesUpload" /&gt; &lt;/div&gt; &lt;div id="info"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The two X-File-Name and X-File-Size attributes aren't showing up in the request headers.</p> <p>SOLUTION: I feel really stupid, turns out the particular jquery.js file I was pointing to was 1.4.4, so I upgraded and now it works! Thanks.</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