Announcement Announcement Module
No announcement yet.
using jquery to make ajax call. not able to invoke URLin controller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • using jquery to make ajax call. not able to invoke URLin controller


    I am using jquery to make an ajax call in my JSP page. i have specified the URL and wrote a method to do the handling in my controller. the method is not being executed. Request you to help in identifying the problem. Please note that i am not using annotation driven option in my dispatcher.

    here is my code for jquery.

    <script type="text/javascript">
    function loadStates() {
    var country_value = $("#country option:selected").val();
    url: '/states.htm',
    data: ({country_id : country_value}),
    success: function(data) {
    alert('inside function');

    this is how i am invoking this function in my jsp using onchange event

    <form:select path="country" id="country" onChange="loadStates();">
    <form:option value="S" label="Select Country"></form:option>
    <c:forEach items="${countryList}" var="country">
    <form:option value="${country.countryId}" label="${}"></form:option>

    here is my handler in the controller

    @RequestMapping(value="/states.htm",method = RequestMethod.GET)
    public List states(@RequestParam int country_id) {
    System.out.println("country id is "+country_id);
    List statesList=customerDAO.listStates(country_id);
    return statesList;

    here is my code in DAO that returns states list based on country value

    public List<states> listStates(int id) {
    return hibernateTemplate.find("from states where country_id="+id+" order by name");

    this is my dispatcher code to invoke the controller

    <bean id="mycustomerDAO" class="customer.customerDAOImpl">
    <property name="sessionFactory" ref="mySessionFactory"/>

    <bean name="/customer*.htm" class="customer.customerController" >
    <property name="customerDAO" ref="mycustomerDAO" />

    if using annotation driven is compulsory please provide an example of how to map these controller classes using annotation

  • #2
    problem solved

    please refer to