---
title: "How to call a controller method after load view successfully in MVC 4?"  
description: "How to call a controller method after load view successfully in MVC 4?"  
author: "Tehran Noorani"  
published: 2023-01-06  
updated: 2023-01-06  
canonical: https://www.mindstick.com/forum/157312/how-to-call-a-controller-method-after-load-view-successfully-in-mvc-4  
category: "asp.net mvc"  
tags: ["asp.net", "asp.net mvc", "mvc"]  
reading_time: 1 minute  

---

# How to call a controller method after load view successfully in MVC 4?

When a [view](https://yourviews.mindstick.com/view/84701/layoffs-in-google-india-2023-view) loads successfully then I want to [update the database](https://www.mindstick.com/forum/160254/how-to-apply-a-migration-to-update-the-database-schema-in-entity-framework-core) [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) using the [controller method](https://www.mindstick.com/forum/34409/controller-method-not-found-error). that controller method does not need to return the list. \
provide me with an easy solution to solve it. Thank you

## Replies

### Reply by Sai Buildrers & Aatma Pvt. Ltd.

You can use ajax [method](https://www.mindstick.com/forum/166/webservice-method) to call Action method in the [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) after page laod of view.

```plaintext
$.ajax({
          type: 'GET',
          cache: false,
          asynch: false,
           url: '/ControllerName/ActionName', 
           data: {abc: “parameter”}, //use if pass parameter in action method one or multiple.
           beforeSend: function(){
               //do something before load data (optional)
               },
           success: function(response){
               //your code for response
               },\
               Complete: function(response){
               // your code when response complete.
               },
            error: function(responce)
 			   {
  				 //if any error occurred show here.
               }
       });
```


---

Original Source: https://www.mindstick.com/forum/157312/how-to-call-a-controller-method-after-load-view-successfully-in-mvc-4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
