I'm sorry in advance if this isn't the clearest post. I'm still having trouble getting my head around what I think is the problem.
I have a Div being populated by some AJAX, the div used to be loaded without the ajax and it all worked fine. But I wanted to have the navigation bar of my site change the content of the div without page reloads like normal links. Because of the site, navigation will be used frequently and I wanted to keep it fast.
There is also a JavaScript function with some php in it that gets the contents of the div and sends it off to my database.
However when I started to use the ajax because only the div is reloaded when navigating and not the main page behind it, the PHP variables in the javascript function are no longer correct after the first change of div content.
So then I thought well If I put the javascript (and PHP) in the same file as the div then it will all ways stay up to date! but when I tried to call the JS function I got an error saying the function didn't exist.
I'm not sure but I presume this is because I populate the div using
Code:
document.getElementById(box_id).innerHTML = data;
which doesn't do javascript as well as HTML.
So now I'm really not sure what to do. I cant send the data to the main page using sessions or any other method I can think of because all the PHP is loaded at the server. I also cant POST it to a new page because I need to get the element by id. There is even a PHP foreach loop in there haha
Anyone have any good ideas? I have been pretty stuck for the past few days.
I can also post the code if it will help but I didn't think it was necessary, its more of a theory question.