I have a button on my MVC view on click of it, it should add a partial view in a 'div', by calling an action which takes an object as a parameter
I tried out some thing like this:
$('#buttonId').onclick(function(){
$('#divid').load(@Html.Action("ActionName","ControllerName",new{parameterName = objectToPass}))
});
but it loads the actionresult/partial view on page load itself not a click of button
Any Idea?
On ajax call success function append result
ajax call=>
and controller must return partialview as result
Load Partial View in a div MVC 4
Recently I want load Partal View in Div , after doing lots of R&D and It's work for me
And In Partal View Action Controller Code
load require a string, you are generating a variable path if you look at your source code it generate something like:
but what you want is:
the code should look like:
but as I can see the load should be working until you click on
#buttonId
Try to use
instead of
Or you can use ajax, for example: