I have two web applications hosted on a server. From one I am trying to do $.post to the second application (spring mvc3). I am able to successfully hit the url of the second application but I do not get response back of the ajax call.
App1 JS Code (http://localhost:7777/app1/test.html) –
var serialisedFormData = $("form").serialize();
$.post("http://localhost:8080/app2/doSomething", serialisedFormData, function (data) {
alert("job done");
}, "json");
App2 Java Code –
@RequestMapping(value = "/doSomething")
public @ResponseBody String doSomething(HttpServletRequest request,
@RequestParam("d") String data) {
try {
... do something here ...
return "done";
}
catch (Exception e) {
logger.debug("Exception occured when doing something", e);
return "failure";
}
}
I achieved it by removing “json” type from my jquery post call.
and adding a header to my response