title: HTTP/1.1 404 Not Found - jQuery POST request to Rails route
body: <p>I have a custom route, in my Ruby on Rails 4 application, which handles post requests sent via jQuery through an <code>onChange()</code> function. </p>
  
  <p>The destination URL is 
     <code>http://0.0.0.0:3000/application/get_programs_for_center</code></p>
  
  <p>Here is my Rails controller which handles the POST request</p>
  
  <pre><code> post '/application/get_programs_for_center', to: 'school_applications#get_programs_for_center'
  </code></pre>
  
  <p>And here is the jQuery which calls this route:</p>
  
  <pre><code>$("#school_application_fls_center").change(function(){
  var center_id = document.getElementById("school_application_fls_center").value;
  var formdata = {center: center_id}; 
  $.ajax({
      url: "/application/get_programs_for_center",
      type: "POST",
      datatype: 'json',
      data: formdata,
      success: function(response){
        var options = $("#school_application_program"); 
        removeOptions(document.getElementById("school_application_program"));
        $.each(response.programs, function(i,item) {
          options.append($("&lt;option /&gt;").val(response.programs[i].id).text(response.programs[i].name)); 
        });
      }
  });
   });
  </code></pre>
  
  <p>It currently is working perfectly in Chrome, however in Safari, Firefox and Opera I am getting this 404 error:</p>
  
  <p><img src="https://i.stack.imgur.com/gGavB.png" alt="enter image description here"></p>
  
  <p>Here is my controller code: </p>
  
  <pre><code>def get_programs_for_center
   respond_to do |format|
    @school_application = SchoolApplication.find(session[:current_app_id])
    @select_program = @school_application.program
    center = params[:center]
    programs = Program.where(fls_center_id: center)
    msg = { :programs =&gt; programs, :message =&gt; "hurray", :program =&gt; @select_program} 
    format.json  { render :json =&gt; msg } 
   end 
  </code></pre>
  
  <p>end</p>