0

I have the following Code on my Client

    var value = {"userId":form.userId.value};

var xhrArgs = {
    url : messageUrl,
    handleAs : "text",
    content: value,
    load : displayMessages,
    error : function(error) {
        dojo.byId("displayArea").innerHTML = "Error aquiring messages";
    }
};
dojo.xhrGet(xhrArgs);
}

And on my server side controller code

@RequestMapping(value = "/getMessages.htm", method = RequestMethod.GET)
public @ResponseBody String showMessageTable(@RequestParam("userId") String userId,ModelMap params)
{

I am getting a 400 error saying

The request sent by the client was syntactically incorrect ()

Could someone explain what i'm doing wrong? I have tested the dojo code with firebug and the value seems to be passing just fine. Thanks!

8
  • You may want to check your Accept header, it should be application/json Commented Aug 30, 2012 at 20:12
  • @BijuKunjummen Do I have to do that even if im moving text? Isn't that for json objects? Commented Aug 31, 2012 at 0:48
  • Oh, okay did not realize that, you have annotated the response with @ResponseBody, Spring will then try and convert the response to json or xml based on the accept header. Just remove the @ResponseBody and it should then try to resolve the view(say a jsp) based on what you are returning from the showMessageTable method. Commented Aug 31, 2012 at 1:53
  • @BijuKunjummen Thanks for the reply! The ResponseBody annotation was something I just added for testing purposes. It doesn't give me the JSP page even if I didn't have it. So my code on the client side looks good? I am still getting the status 400 error. Also to note. when I put the url, the exact one that dojo is sending back in the address bar it takes me to a new page and displays data. So I know the MVC is working. Commented Aug 31, 2012 at 13:03
  • Just to confirm, with DOJO when you send a request, is it a normal POST or GET with the userId field a normal request parameter and NOT a json. Commented Aug 31, 2012 at 13:37

1 Answer 1

1

It might be helpful. visit to this URL : http://maxheapsize.com/2010/07/20/spring-3-mvc-ajax-and-jquery-magic-or-better-simplicity/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.