How should Ajax routes be configured in MVC?

Should Ajax MVC requests be displayed in the same way as regular requests in an MVC structure?

For example: Let's say I want to check and see if the username is accessible via ajax and there is a method on the controller that performs this area of ​​work. Am I just adding a route that maps the ajax request to a specific controller method, or is there a better way to achieve this?

Thanks in advance.

+3
source share
2 answers

When you request an ajax call to retrieve data or information, you pass the URL to this page. But in the case of MVC, the url becomes the controller / function _name. Therefore, in the ajax call url, this should be the name of the controller / function _name. And since this kind of request is handled by MVC, you do not need to worry about it.

+2
source

They use the same entry and flow point. Ajax or not, it's just a request for routing.

0
source

All Articles