% <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src="/MyApp/js/jquery.js"></script> <script type="text/javascript"> function doAjax() { alert('yes'); $.ajax({ url: 'register.html', data: ({name : "me"}), success: function(data) { $('#time').html(data); } }); } </script> </head> <body> <form action=""> <button id="demo" onclick="doAjax()" title="Button">Get the time!</button> <div id="time"> </div> </form> </body> </html> @RequestMapping("/hello") public ModelAndView helloWorld() { return new ModelAndView("hello", "message", "Spring MVC Demo"); } @RequestMapping(value = "/register", method = RequestMethod.GET) public @ResponseBody String registerUser(@RequestParam String name) { String result = "Time for registration" + name + " is " + new Date().toString(); return result; } <script type="text/javascript"> $(function(){ $('button').click(function(e){ e.preventDefault(); doAjax(); }) }) function doAjax() { alert('yes'); $.ajax({ url: '/register/', data: ({name : "me"}), success: function(data) { $('#time').html(data); } }); } </script> </head> <body> <form action=""> <button id="demo" title="Button">Get the time!</button> </form> <div id="time"> </div> %