Suppose the following drop-down menu is written in a file called views/home/index.cshtml. (Razor is not used)
<select class = "title_list" name = 'Title'> <option value = 'title_select>Please select a title</option> <option value = "movie_title">is a movie</option> <option value = "drama_title">Drama.</option>
For example, if I want to display a movie screen (information) without transition when you select a movie, or display a drama screen (information) when you select a drama, how do you use ajax? Is that okay?
I've been investigating a lot, but there are few combinations of ajax and .netMVC.
What I don't know personally
-Should you prepare two view files for each movie and drama?
・ How to switch view file with jQuery = ajax (I don't know which method to use or how to specify the path)
Even if it is not detailed code, it may be in the order of writing such as implementation policy (create two view files → write get method in js file). Thank you.
Answer # 1
Ajax is a mechanism that enables asynchronous communication with the server.
Even with Ajax, normal server-side processing may not change.
"Request" and "Response".
In server-side processing, POST transmission from the client side is received as a "request", and some result is returned as a "response", right?
It is the same.
If it is MVC, requests should be distributed by some kind of routing.
Prepare a controller to receive requests from Ajax and return the response in the view.
However, the view is not normal HTML, but just a string, for example. Most of them are in JSON format.
In this case, a request to send "Title"
Receive the result, search something on the server side, and create a "response" that returns the result.
When you receive a "response", process it and reflect it in the HTML.
The flow is roughly like this.
I don't know if there is an Ajax article on ASP.NET MVC itself, but
Just by matching the way to ASP.NET MVC, thinking, receiving a request → processing and returning the response does not change whatever.
-Should I prepare two view files for each movie and drama
Since the response part is dynamic only with the character string, it may be one.
-How to switch the view file with jQuery = ajax (I don't know which method to use or how to specify the path)
As already written, the request is just the value of Title, which determines the information to be acquired by the controller.
Maybe I just don't understand the meaning of this sentence.
It would be helpful if you could write more concretely ...
- Jquery study notes without new construction in detail
- JQuery implementation of cascading drop-down box effect examples
- jquery infinite cascading drop-down menu simple example demonstration
- jQuery + jsp drop-down box linkage method to obtain local data (with source code)
- jquery achieve secondary navigation drop-down menu effect
- jQuery Mobile page returns without re-get
- Simple use of uploadify 31 without jQuery refresh refresh
- jQuery custom multi-select drop-down box effect
- Multi-select drop-down list based on jquery
- jquery + css implement drop-down list function
- Non-refresh linkage of drop-down box based on jQuery Ajax
- jQuery implements drop-down menus to dynamically add data
- ruby - how to update data without screen transition in rails
- Method for ajax request back to json data and render HTML in jQuery
- jQuery click on other part of the page to hide the drop-down menu function
- Multi-select drop-down list function implemented by jQuery + vuejs
- Jquery achieve secondary navigation drop-down menu effect example
- Jquery multi-level tree drop-down menu example code
- jquery - i want to transition the parent screen within the page by clicking the link in modal
- even if you send formdata() with jquery, the input value cannot be received with php
- php - i don't understand why security measures for image uploading are so difficult
- php - i don't know how to not use formdata when uploading multiple images with ajax
- how to apply css to external html obtained with jquery
- ajax ➡ahtml read ➡link to bhtml