3

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

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.

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Could you give an example of an Ajax function calling a URL of the form "controller/function_name"
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.