使用AJAX和方法POST提交表单

I have a difficulty in implementing an MVC system.
I have a simple comment system, which makes the record when sent via POST or via AJAX.

a) Should I separate the 2 controllers in Comment_Ajax and Comment_Post
b) or should I just keep a controller and and check the sent method (is_ajax()) to perform the necessary actions.

Form method 'Post' redirects to the page of the post and form method 'Ajax' only makes a reload in the comments.

I would go with version b, keeping related methods together. Keep DRY: Don´t Repeat Yourself.

What you are doing are 2 actions (methods/functions) of one controller, which is pefectly valid MVC. Usually a controller has one action "render" (display page if no parameters are present), and can have multiple actions like save, update, submit, render_ajax etc.

It is not a good option to create more controllers.

I didn't understand your statement "Form method 'Post' redirects to the page of the post and form method 'Ajax' only makes a reload in the comments".

Generally we can comment to a post if we are in corresponding post page, again you are saying 'post' will redirect to post page.

Based on Client requirement we will go for 'reload the page' or 'just updating commnets section with AJAX'.

And moreover, what ever is the process you follow, Just write one method like saveComment(); and call this method, through form action if it is Post, or mention this method in AJAX call.