Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery $.ajax(), $.post sending "OPTIONS" as REQUEST_METHOD in Firefox
    text
    copied!<p>Having trouble with what I thought was a relatively simple jQuery plugin...</p> <p>The plugin should fetch data from a php script via ajax to add options to a <code>&lt;select&gt;</code>. The ajax request is pretty generic:</p> <pre><code>$.ajax({ url: o.url, type: 'post', contentType: "application/x-www-form-urlencoded", data: '{"method":"getStates", "program":"EXPLORE"}', success: function (data, status) { console.log("Success!!"); console.log(data); console.log(status); }, error: function (xhr, desc, err) { console.log(xhr); console.log("Desc: " + desc + "\nErr:" + err); } }); </code></pre> <p>This seems to work fine in Safari. In Firefox 3.5, the <code>REQUEST_TYPE</code> on the server is always 'OPTIONS', and the $_POST data does not appear. Apache logs the request as type 'OPTIONS':</p> <pre><code>::1 - - [08/Jul/2009:11:43:27 -0500] "OPTIONS sitecodes.php HTTP/1.1" 200 46 </code></pre> <p>Why would this ajax call work in Safari, but not Firefox, and how do I fix it for Firefox?</p> <pre> Response Headers Date: Wed, 08 Jul 2009 21:22:17 GMT Server:Apache/2.0.59 (Unix) PHP/5.2.6 DAV/2 X-Powered-By: PHP/5.2.6 Content-Length 46 Keep-Alive timeout=15, max=100 Connection Keep-Alive Content-Type text/html Request Headers Host orderform:8888 User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive Origin http://ux.inetu.act.org Access-Control-Request-Method POST Access-Control-Request-Headers x-requested-with </pre> <p>Here is a picture of the Firebug output:</p> <p><img src="https://i.stack.imgur.com/Tid8P.jpg" alt=""></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