Trying to trigger an ajax call

Trying to trigger an ajax call

Hi Folks,

    I'm trying to call a controller with an Ajax request though the url user/MyAjaxCall.  console.log() prints some irrelevant url as and call not biked. Please give me a clue to proceed and I'm struck. Below is the code. I'm trying


  1. package net.practice;

  2. @Controller
  3. @RequestMapping(value = "/user")
  4. public class UserController {

  5. @RequestMapping( value = "/MyAjaxCall", method = RequestMethod.POST)
  6. @ResponseBody
  7. public String MyAjaxCall(@RequestBody User usrObject, @ModelAttribute("model") ModelMap model,                   String order) {
  8. System.out.println("Value Received" + order);
  9. System.out.println("Name " + usrObject.getFirstname());
  10. return "ajaxTest";
  11. }
  12. }

"ajaxTest" is an another ftl (Freemarker template) file. Is it something wrong with ftl file and ajax call ? Please comment your ideas. 


Ajax Call 

  1. <html>
  2. <head><title>ViralPatel.net - FreeMarker Spring MVC Hello World</title>
  3.     <script type="text/javascript">
  4.        $().ready(function() {    
  5.          
  6.           $('#reset').click(function() { 
  7.           
  8.           $('input[type=date], input[type=checkbox], input[type=text]').each(function () {
  9.             alert($(this).val());
  10.             $(this).val("");
  11.             alert('Reset Done');
  12.         });
  13.           });
  14.           
  15.           $('#getData').click(function() {  
  16.           $.ajax({
  17.            url: 'user/MyAjaxCall',
  18.            type: 'POST',
  19.            dataType: 'JSON',
  20.            data: {order: 'Client_Call'},
  21.            success: function(data) {
  22.            alert('Ajax Call Succeed');
  23.            }, 
  24.            error: function(data) {
  25.           
  26.            console.log(arguments);
  27.           
  28.            }
  29.           
  30.         });
  31.           });
  32.                    
  33.         });        
  34.          
  35. </script>
  36. <body>
      1.   <form name="Use1r" action="index.ftl" method="post"
        1. <table border=" 10" width="50" height="25">
  37.    <tr>
  38.    <td>
  39.    <input type="button" value="   Save   " id="getData" />
  40.    </td>
  41.    </tr>
  42.    </table>
  43.    <input type="reset" value= "Reset AML" id="reset"> 
                1. </form>
  44.   </fieldset>  
  45.     <#list model["userList"] as user>
  46.    <tr>
  47.    <td>${user.firstname}</td>
  48.    <td>${user.lastname}</td>
  49.    <td><input type="text" id="forCheckBox" name="forCheckBox"
  50.    value = ${user.checkValue}> </td>
  51.    <td>
  52.    <input type="button" id="forUpdateButton" name="forUpdateButton" value="Update" /> 
  53.    </td>  
  54.    </tr>  
  55.     </#list>
  56.   </table>
  57. </div>  
  58. </body>
  59. </html> 

I referred some already existing queries on the same question but had no luck. Please guide me. Please is what printed in console.log and how shall understand this error. 

Please help and Thanks.