As I tackle a project that involves loading elements via AJAX within a CMS-type software, I find myself restricted in accessing the AJAX code and its callbacks.
One specific challenge I face is running my function only when a certain part of the page is loaded, but with the involvement of AJAX, this becomes more complex. What approach should I take in handling this situation?
Below is an excerpt from my JavaScript code (which works independently): Fiddle:
var personalitet = document.getElementById("personalitet").innerHTML;
document.getElementsByName("form[5553]")[0].value = personalitet;
I've attempted different methods such as:
document.getElementById("personalitet").onload = function() {
document.addEventListener("DOMContentLoaded", function(event) {
window.onload = function(){
However, none seem to work since the elements are not yet loaded when my script attempts to access them.