Using this ajax request I am returning a view fragment of populated html to insert into a particular div within the layout.
my question is how do I declare #theDiv, I have the id available at the point where the view fragment is constructed (within the view_Controller).
Ideally I would return some json at the same time for instance, specifying:#theDiv, and any other parameters such as which nav bar element should be active etc….
$.ajax({
type: "POST",
url: "controller/view_Controller.php",
data: dataString,
cache: false,
dataType: "html",
success: function(html){
$('#theDiv').html(html)
};
});
You need to build an array of information on the backend:
And in your JS:
I don’t quite understand what you mean by specifying success and error — do you mean you want your script to be able to define the Javascript to be called on success?