Praveen Rao Chavan.G
Praveen Rao Chavan.G

Reputation: 2860

Get div Source code to HTTP Post to Controller ASP.NET MVC

I have an MVC view in which I construct a div with some dynamic data.

<div>
   <p>Dynamic content</p>
</div>

Once the Div is finished rendering I want to hit a controller action method with a parameter of ( the inner source content of the div ).

This is running in a web job so there is no user interaction to click a button.

I tried to post the div inner HTML content, which works fine.

document.getElementById("divContent").innerHTML

but I want this to happen after div has finished rendering.

Upvotes: 2

Views: 231

Answers (1)

matt
matt

Reputation: 133

$( "#DivId" ).load(function() {
          $.ajax({
            type: 'GET',
            url: '/Controller/Method',
            data: { ParamName: document.getElementById("DivId").innerHTML},
            success: function(result) {

            }
          });
        });

this event will fire when the div is loaded.

Upvotes: 1

Related Questions