If your DIV has a CSS ID of, say, "MathOutput", so it looks like <div id="MathOutput"></div> in your HTML page, then in the Javascript function where you inject the math into the DIV based on the database info, at the end of that function, place a call to the MathJax Typeset method on the MathJax queue, as MathJax.Hub.Queue(["Typeset",MathJax.Hub,"MathOutput"]). The array input to the Queue method is the MathJax internal way of representing a callback, in this case to the Typeset method (first field) in the MathJax.Hub object (second field), with a parameter identifying the DIV by its CSS ID (third field) so that MathJax can focus on typesetting the contents of that DIV instead of the whole document. You need to use the Queue because of the issues of synchronization -- MathJax runs asynchronously, so it needs to be sure to finish its other tasks before Typeset is called again. I'm sure from what you describe that this is what you need -- does this explanation help you understand it?
Thanks,