Mitchelln11
Active member
- Joined
- Apr 10, 2020
- Messages
- 39
- Programming Experience
- Beginner
I want to fetch a REST API endpoint, but I want to do it on button click.
Is there a proper way to do this?
I'm using the following:
```
<input type="button" value="Fetch Parks" onclick="location.href='@Url.Action("FetchParkApi", "Park")'" />
```
which is a button that's meant to run a method called "FetchParkApi" that's located on the ParkController.
I have also used :
```
@Html.ActionLink("Fetch Parks", "FetchParkApi", "Park")
```
These methods work, it's only that the method, when finished, wants to go to a page called FetchParkApi which is on the ParkController. I just want it to go back to the Index view of the Park
Is there a proper way to do this?
I'm using the following:
```
<input type="button" value="Fetch Parks" onclick="location.href='@Url.Action("FetchParkApi", "Park")'" />
```
which is a button that's meant to run a method called "FetchParkApi" that's located on the ParkController.
I have also used :
```
@Html.ActionLink("Fetch Parks", "FetchParkApi", "Park")
```
These methods work, it's only that the method, when finished, wants to go to a page called FetchParkApi which is on the ParkController. I just want it to go back to the Index view of the Park