Hi,
How to post Data to action method via ajax,jquery and load the partial view to a div which is returned from the method?
Thanks.
I googled "mvc update partial view jquery ajax" and here is one of the results
Thanks. When i searched then i didn’t end up with the link you provided. I will look into this.
Google being partial.
Hi abhi0410,
Thanks for your post.
According to your description,
abhi0410
post data to action method via ajax and load partial view ?
please try this:
$(".SelectedCustomer").change( function (event) { $.ajax({ url: '@Url.Action("GetPartialDiv", "YourController")', data: { id : $(this).val() /* add other additional parameters */ }, cache: false, type: "POST", dataType: "html", success: function (data, textStatus, XMLHttpRequest) { SetData(data); } }); });
More information:
ASP.NET MVC Partial view ajax post?
Rendering a Partial View and JSON Data Using AJAX in ASP.NET MVC
Rendering a simple ASP.NET MVC PartialView using JQuery Ajax Post call
Hope this can be helpful.
Best Regards,
Eileen
check these links
var data = new{
// properties declaration goes here..
}
then assign the values to data as:-
data.PROPERTY1 = $("#ID").val();
//simply others
$(".ClassName").change( function (event) { $.ajax({ url: '@Url.Action("ACTION", "CONTROLLER")', data: { id : $(this).val() /* add other additional parameters */ },//or simply data cache: false, type: "POST", dataType: "html", success: function (data) {
$("DIV_FOR_PARTIAL_VIEW").html(data);//Let the action return a view to be displayed in the div. } }); });
Hope this helps.
Thanks