开发者

How should Ajax routes in MVC be setup?

开发者 https://www.devze.com 2023-03-02 19:45 出处:网络
Should MVC Ajax requests be mapped the same way as regular requests in a MVC framework? 开发者_如何学JAVA

Should MVC Ajax requests be mapped the same way as regular requests in a MVC framework?

开发者_如何学JAVA

For example: Say I want to check and see if a username is available via ajax and have a method on a controller that performs this scope of work. Do I simply add a route that maps the ajax request to a particular controller method, or is there a better way to achieve this?

Thanks in advance.


When you are asking a ajax call to fetch data or information you pass the url to that page. But in case of MVC the url becomes controller/function_name. So in url of the ajax call it should be controller/function_name. And since this kind of request is handled by MVC you don't need to worry about it.


They use the same point of entry and flow. Ajax or not, it's just an request needed of routing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号