I'm trying to imitate the ASP Master/Content page concept in PHP/jQuery environment, in which I can run an AJAX call in master page to include the content page dynamically. I added a div place holder in my master page and used the following code to add the content page dynamically:
$.ajax({
url: "ajax.php"
, type: "POST"
, data: {'cmd' : 'dashboardView'}
, success: function(response, sts){
if(response.flag)
{
$("#divMainContentPHolder").html('');
$("#divMainContentPHolder").html(response.mainContent);
}
else
alert(" unsuccessful!");
}
, dataType: "json"
});
The code is working fine, but the problem is, since there are some javascript functions in the content page, if the above function runs for the second time, the functions ill be duplicated, so that the run multiple times. I was wondering if someone could help me understand what is the best practice for such development. thank you