facebook

AJAX and the Controller – Best Practices

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #276731 Reply

    Robert Byrne
    Member

    I have searched far and wide for an answer to this question: Is it a good practice to send AJAX requests to the controller of a web application?

    For instance, my url’s point to the controller and pass in an action. That controller executes the action and forwards the request to a jsp page. But using AJAX I would set a few headers in the response and use the writer to send my XML or JSON text back to the client.

    I just started a new job and they are doing something else with AJAX requests. They are sending the request to a jsp page which creates HTML, though setting the header to text, and it goes back to the client that way. I guess it works but it makes me squirm deep down inside and I need to know why so I can explain it to them and do it right. All the work I’ve done with AJAX has always involved JSON or XML returns and never a JSP intermediary. <shiver>

    I am thinking of using JSON-RPC-JAVA as my AJAX controller. It’s good? IBM is promoting it, along with the dojo tool kit.

    Any thoughts, ideas, resources would be escpecially helpful.

    Thanks so much,
    -Robert

    #276747 Reply

    Robert Byrne
    Member

    I understand that it is a common practice to send HTML back from the AJAX request, it’s just I’ve never done it.

    However, the real question is whether it is a “good practice” to send AJAX request to the application controller, in the model view controller design framework, or if it is better to specify a seperate controller for AJAX requests?

    And is it proper to use a JSP page during my AJAX request? It may be completely fine, even beneficial. I could probably argue a case for it and a case against it. Just wanted to get other opinions on this.

    -Robert

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: AJAX and the Controller – Best Practices

You must be logged in to post in the forum log in