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 7604377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:53:39+00:00 2026-05-30T23:53:39+00:00

I am trying to make an ajax call using jquery in my spring MVC

  • 0

I am trying to make an ajax call using jquery in my spring MVC based application.

Below is my ajax controller

@Controller
@RequestMapping("/ajax/*")
public class AjaxController extends BaseController {

    private static Logger log = Logger.getLogger(AjaxController.class);

    @Autowired
    private ICountryService countryService;

    @RequestMapping(value = "/findCountriesByRegionId", method = RequestMethod.GET)
    public @ResponseBody
    List<Country> findCountriesByRegionId(
            @RequestParam(value = "regionId") int regionId) {
        log.info("finding countries by region id [" + regionId + "]");
        List<Country> countryList = countryService.findByRegionId(regionId);
        return countryList;
    }

and Below is my javascript code

    function populateCountriesByRegionId(regionId) {
    alert("11");
    $.getJSON("ajax/findCountriesByRegionId", {
        regionId : regionId
    }, function(countryList) {
        alert("2");
        $("#countryId").empty();
        // $("#countryId").html("");
        var options = $("#countryId");
        options.append($("<option />").val('0').text(""));
        $.each(countryList, function() {
            options.append($("<option />").val(this.countryId).text(
                    this.countryName));
        });
    });
}

But my controller method is not getting called at all.

When i am on page with url like http://localhost/myApp/emp/new and my ajax url is like ajax/findCountriesByRegionId it gives me error saying no mapping for url myapp/emp/ajax/findCountriesByRegionId.

Why its checking for url myapp/emp/ajax/findCountriesByRegionId. It should be myapp/ajax/findCountriesByRegionId

When I sue url like /ajax/findCountriesByRegionId (added / at the begining) , nothing happens. No error at all. No conroller invoked.

I wanted to put all my ajax methods in one controller and call those while executing other controller like emp in this case.

Please help.

  • 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-30T23:53:40+00:00Added an answer on May 30, 2026 at 11:53 pm
    • first don’t use a relative URL in your page. $.getJSON("/myApp/ajax/findCountriesByRegionId",
    • second don’t have the /* at the end of your mapping at the class level for your controller. Make it just /ajax.
    • Third, make sure you can invoke the controller given the url path before trying to hit it with your jquery and make sure the json looks like you expect. Point chrome to http://localhost/myApp/ajax/findCountriesByRegionId?regionId=1
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying to make my first AJAX with JSON call using jQuery and CodeIgniter.
I am trying to make two ajax requests in parallel using jQuery like this:
I am trying to make an ajax json callback using a .net application. So
Am I missing something? I'm trying to do a simple ajax call using jquery
I'm trying to make an ajax call to grab session data to insert into
Trying to make a MySQL-based application support MS SQL, I ran into the following
I'm trying to figure out the best way to make an AJAX call to
I am trying to make an onchange call on a select box.For my application
i am just trying to make a simple ajax call to shorten a url
I'm trying to make a RESTful api call from the android emulator (using android

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.