0

In my client, I send a request using ajax to a Spring controller. This last can intercept it, but when I return a value, I can't can't have it in my client side.

Client code :

$.ajax({
           type: "GET",
           data: {name : "name"},
           url: "/web/private/frontend/accueil/dateHistorique.html",
           success: function(msg){
                alert("Hello");
           }
        });

Server side code :

        @RequestMapping(value="/dateHistorique.html", method = RequestMethod.GET)
public @ResponseBody Map<String, String> getAllowedDate(@RequestParam String name) {
    System.out.println("***********************************" + name);
    AllowedDates allowedDates = new AllowedDates("1","20");
    Map<String, String> responseMap = new HashMap<String, String>();
    responseMap.put("Name", "Marouane");
    return responseMap;
}

I can see the out put in the server : ********name but always don't have a response. Thnx

Marouane Gazanayi
  • 5,063
  • 6
  • 39
  • 58
  • '/web/private/frontend/accueil/dateHistorique.html' is looking like a filesystem path. sure you can call it via a browser? – schellmax Mar 10 '11 at 14:20
  • It's just a mapping :) it's working now, I just need to return an object, that can be transformed to JSON. how to do ? – Marouane Gazanayi Mar 10 '11 at 14:27
  • don't know spring but found this: http://spring-json.sourceforge.net/ (taken from http://stackoverflow.com/questions/1601992/spring-3-json-with-mvc) – schellmax Mar 10 '11 at 14:35
  • 1
    Use firebug in your browser so you can se more information about the request. In the tab Net you'll see the requests and the responses. Can you tell us the status code of the response is 200 and if the response content is what you are expecting? – Javi Mar 10 '11 at 15:21
  • I didn't add Thnx all :) – Marouane Gazanayi Mar 10 '11 at 15:53

1 Answers1

0

Should add Jackson to my pom and <mvc:annotation-driven /> to my mvc-servlet-context

Marouane Gazanayi
  • 5,063
  • 6
  • 39
  • 58