I'm trying to get data from Controller while clicking something. I get the response and success, but the response data returns the whole page(returned content is perfectly O.K.). I can't figure out how to replace the current page with the returned data. When I use .html on the top most element in the tree I get blank page like the returned data was not there (but the whole data is visible via console.log(data), it starts with ). How can I replace the current page with the new whole page content ajax returned? I'm doing it like this and it doesn't work:
JavaScript:
$(document).ready(function(){
$(document).on('click','#name',function(){
$.ajax({
url: "{{path('myPathOne',{'status' : 'ONE'})}}",
type: "POST",
cache:false,
data: { 'status' : status },
success: function(data) {
$(document.body).html(data);
}
});
});
});