Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:20:42+00:00 2026-05-24T20:20:42+00:00

I am creating an ajax request and building the url as follows: function submitYear(year){

  • 0

I am creating an ajax request and building the url as follows:

    function submitYear(year){
    new Ajax.Request('update_make/'+year, { method: 'get'});
}

When I am at the new action for my car_infos controller, http://localhost:3000/car_infos/new this Ajax request works fine. I get a request that says:

Started GET “/car_infos/car_infos/update_make/2011”

The route matches up and all is well. However, if there is an error in the create the url becomes http://localhost:3000/car_infos and then when my ajax request triggers I get this with a routing error:

Started GET “/update_make/2002”
No route matches “/update_make/2002”

Here is what happens in my controller when create fails:

format.html { render :action => "new" }

I understand why I am getting the routing error, because I don’t have a route set up as /update_make/. Here is my route.

    match 'car_infos/update_make/:year', :controller => 'car_infos', :action => 'update_make'

So two questions.

  1. Why does my get request change when the url changes from car_infos/new to car_infos

  2. How do I resolve this so when I create the url in the javascript it works for both cases? I don’t think putting a route for /update_make is the answer. If I redirect to /new then I lose the field values and the error message.

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:20:43+00:00Added an answer on May 24, 2026 at 8:20 pm
    1. You’re sending your ajax request to a relative path, so if your browser location path changes the request path changes too. The browser location path could be changing because of a redirect in Rails or in javascript.

      Is this a typo (the 2x “/car_infos”)?

      Started GET “/car_infos/car_infos/update_make/2011

    2. You could spell out the absolute url in your javascript:

      function submitYear(year){
          var absoluteUrl = 'http://' + window.location.host +
                              '/car_infos/update_make/' + year;
          new Ajax.Request(absoluteUrl, { method: 'get'});
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have jQuery.ajax() creating a request to a url (cms2/docman/dir/%id) (%id is a numeric
On the success function of jquery ajax request i am creating div with a
This is the XMLHttpRequest: $.ajax({ method: get, url: getPage.php, data: $data, dataType: 'json', timeout:
I am creating a chat using Ajax requests and I'm trying to get messages
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
I have an Ajax request that returns search results, and I am dynamically creating
I am creating a PHP/AJAX chat client. The application makes an AJAX request to
I found WaitForPageToLoad,WaitForCondition and popup. I have an ajax request which is creating some
I have an AJAX request that grabs the source of Wikipedia pages: $.ajax({ url:
I'm having trouble with a synchronous AJAX request. I am creating a web application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.