0

Here's the desired flow that I am looking for :

  1. Large data (table) is passed to Spring Controller through a javascript function.
  2. Controller processes the data.
  3. Controller returns a new ModelAndView
  4. Render this new ModelAndView on the screen.

I am trying to send data to controller using an Ajax call. However, the returned modelandview ends up as a response to the ajax call, and as a result does not get rendered on the screen.

Is there a away I can avoid this behavior. Or perhaps, an approach to achieve the flow I am looking for?

Thanks.

2
  • I was looking for something similar to this as well, unfortunately I had to use jQuery and that Ajax response to change the data. I do not believe you can do what you want without a page refresh. Assuming you are using Java, the model is rendered to the view server side before loading on the client side. (I am fairly new to MVC, so I may be wrong, if there is another solution, I want to hear it as well). Commented Oct 2, 2012 at 19:58
  • If I just invoke the controller method mapping url on the browser (that is, not use an ajax call), the new ModelAndView gets rendered like a charm. But ofcourse, in this case, I have not passed my data to the controller. So I'm basically looking for a way to pass the data to the controller. Commented Oct 2, 2012 at 20:03

1 Answer 1

1

If you want to refresh the whole page, using AJAX doesn't bring any advantage.

If you only want to refresh some part of the page, then you need to provide a JavaScript callback function that will use the AJAX response, and modify the DOM of the current page.

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.