I am studying ASP MVC and I ran into a problem. It is necessary that when you click on a table cell from a view, a request is sent to the controller, which returns PartialView and displays it on the page. Sending a request to the controller:

 $('td').click(function() { $.ajax({ url: '/Home/OneDay', type: 'POST', dataType: 'html', success: function(data){ $().html(data); }})}); 

The controller itself:

 [HttpPost] public ActionResult OneDay(string id) { return PartialView(); } 

The problem is that the partial view sent back is not displayed on the page.

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

From the jQuery Documentation: .html(string) Set the HTML contents of each element in the set of matched elements. (Sets HTML to all found items)

 success: function(data){ $().html(data); } 

You do not look for elements $().html(data);

  • Thank you, figured out. - Nikita Vorobyev