Q: Data not going to controller using Ajax I am new to AJAX and I am trying to send some data to the controller using the AJAX. on clicking the button "Start Event", nothing is happening..
This is my jsp page where I have written the AJAX code
<c:forEach items="${scheduledEvents}" var="event">
        <div class="col-md-3" id="eventId">

            <div class="card-counter primary">
                <div id="head" class="card-counter head-color"></div>
                <span class="count-head">${event.eventName}</span> 
                <br> 
                <span class="count-name">Date : ${event.date}</span>
                <span class="count-name">Location : ${event.location}</span>
                <span class="count-name">Hosted By : ${event.hostName}</span>
                <span class="count-name">Description : ${event.description}</span>
                <br>
                <br>
                <div class="count-join">
                <button class=" btn" id="${event.linkId}" style="background-color: #cc3300;"><font style="color: white;">Start Event</font></button>
                </div>

            </div>
        </div>
    </c:forEach>
    <script type="text/javascript">
    $(function() {
        $('.count-join').on('click',function(){
                    var eventData = $(this).attr("id")
                    .ajax({
                        url : 'startEvent?data=' +eventData,
                        type : 'GET',
                        contentType : 'application/json',
                        success : function(data){
                            $
                            .get(
                                    '${pageContext.request.contextPath}/startEvent',
                                    function(data,status) {
                                        $("#eventId").html(data);
                                    }
                                    );
                        }
                    });
                });
    });
    </script>

And this my controller mapping
@RequestMapping(value="/dashBoard/startEvent")
public ModelAndView startScheduledEvent(@RequestParam("data")String data)
{
    System.out.println(data);
    return new ModelAndView("DashBoard");
}

Where am I wrong? please give some detailed explanation as I do not know much about AJAX. Thanks in advance.

A: As per you controller @RequestMapping, you have missed the /dashBoard in ajax call.
