Altedirerrege
New Member
One of my pages relies heavily on making AJAX calls to another file to retrieve HTML for various elements on the page.I am using AJAX calls, because my file returns specific elements depending on what I \[code\]POST\[/code\] to the page am I making the call to.I'm starting to realise that this was a bad idea, because there is a delay between clicking on elements on the page and the HTML being returned and injected in to the DOM. I think this is mainly because the page I am making the call to makes a connection to my MYSQL database.So I'm looking for another solution... but which one do I choose?
- Put all of my required elements in the DOM (display: none) at the bottom of the page, so that they can be cloned and injected where required?
- Eliminate the need for my returning AJAX file to access the MySQL database. Essentially having a file dedicated to receiving requests and returning back the correct DOM element.
- Store the element structures in my JavaScript code, ready to inject in to the DOM? Even though at the moment I have a single function dedicated to this, so that these elements are always structured the same.