Spring MVC and Prototype JavaScript -
I am trying to call a Spring MVC controller through an AJAX call via javascript method. Javascript is using prototype library AJAX call. The controller throws JSP as output. I am able to hit the controller because I can see in the log message, but the feedback starts to lose. What could be the issue. This code is ....
Submit NewwegeCell () {
Warning ('test');
New Ajax. Request ('SimpleApp / home.htm',
Method: 'Post', Parameter: $ ('FormId'). Serialize (True), Complete on: Sorsult
});
} Function Shortslutt (Results Data) {/ alert (resultdata.responseText); **** // This method is not called ..... ****
}
home .htm Indicate this controller
Public Model and View Handle Request (HttpServletRequest Request, HttpServletResponse Response) exception {System.out.println ("Home Controller:" + + + I) throws; Return a new model and view ("home"); --- It throws home.jsp
for your help.
If you receive an Ajax response and see what its content is, then firebug (Net tab ), It may be understood to go back to the entire HTML page but Javascript is telling something about JSON objects that the controller has just done. It may be that your admin add an AJAX GET property, where you can use plain JSON in the response body rather than return to the model audiovisual. Try using the SUC in the prototype. Maybe it may be that
function submitNewAjxCall () {new Ajax.Request ('SimpleApp / home.htm? Ajax = true', {method: 'post', parameter: $ ('FormId'). Cyrillic (true), mutual: function (transport) {warning (transport.responseText);}}); }
Edit: To write directly JSON (such as using serializer) you can use it in your (annotated) spring controller:
The public name getByName (@RequestParam (value = "name", required = true), name of the string, and @RequestMapping (value = "/dosomething.do", method = RequestMethod.GET, params = "ajax = true" HTTPServe response response) {response.setContentType ("application / json"); {OutputStreamWriter OS = Try New OutputStream Water (try.getOutputStream ()); & Lt; DomainObjects & gt; Results = this.domainObjectService.getByName (name); String Data = New JSONSerializer () Serialize (results); Os.write (data); Os.flush (); Os.close (); } Hold (IOException e) {log.fatal (e); }}
Comments
Post a Comment