Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's probably not a Sinatra / Jquery interaction problem, instead, it's an Ajax "cross domain security" problem.</p> <p>Your original problem could be due to the fact that you've got your form and your server hosted on different domains. XMLHTTPRequests such as <code>.get</code>, <code>.post</code>, <code>.ajaxForm</code> and <code>.ajaxSubmit</code>, will fail if they are on different domains. Check your logs on the app that receives the post, and you might see something like <code>"OPTIONS behavior_count" 404</code> in the log file. Basically, it will work when you hit the app directly, but when you try to use AJax to do it, and that Ajax is accessing it from a different domain, i.e., the "action" option on the form has <code>"http://some.differentdomain.com/behavior_count"</code> in it.</p> <p>That would explain why your simple example works, because the form and the post are happening on the same application / same domain.</p> <p>I had the same problem for five hours just now; I wanted to use a generic "comments" application and have other applications be able to post to the one central application, on a different domain. It won't work. But then I made the two applications into one, and everything was fine. Alternately, you can try to use JSONP to make it work and still keep the two applications separate. </p> <p>I read "<a href="https://stackoverflow.com/questions/1099787/jquery-ajax-post-sending-options-as-request-method-in-firefox">jQuery $.ajax(), $.post sending “OPTIONS” as REQUEST_METHOD in Firefox</a>", which helped. </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