When using MVC you are calling actions that then load a view and a parent layout/masterpage. When you wish to load a view using AJAX though and then stick that content say inside a div with an id of content you would end up loading all the layout and stuff as well as you are just calling the action.
How do I get around this? Is their some way to say if calling this action using AJAX then don’t bother with the layout and just shove the view inside the div?
Any code examples would be much appreciated. Thanks
in your ajax response HTML you can select only the div or elements you want to display
lets suppose your ajax calls looks like this:-
just give your response HTML to jquery
$(responseHtml)and select the content you want$(responseHtml).find('.div-inside-response')and set it in your current page div$('.div-on-current-page').html( $(responseHtml).find('.div-inside-response') );.