1
<p><input type="button" id="ajax" value="click here!"/><br/>
<script type="text/javascript">
  $(function () {
      $('#ajax').click(
          function () {
              $.ajax({
                  type: 'get',
                  url: 'https://example.com',
                  success: function (data) {
                      alert("OKAY");
                  },
                  error: function (data) {
                      alert("NG");
                  }
              });
          });
  });

I want to GET request using Ajax in Rails but sent options request.

This is an error shown console log

OPTIONS https://example.com 405 (Method Not Allowed)

faara
  • 159
  • 1
  • 1
  • 5
  • Because you are attempting to make a cross-domain request [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) Check [here](http://stackoverflow.com/questions/17333013/jquery-ajax-post-request-throws-405-method-not-allowed-on-restful-wcf#17333053) it might help you – Mahesh Singh Chouhan Apr 26 '17 at 15:46
  • Try sending your AJAX request to a URL that's intended to accept AJAX requests. `http[s]://example.com` is not. – ArtOfCode Apr 26 '17 at 17:32

0 Answers0