Skip to content

jQuery load() and MathJax

Davide P. Cervone edited this page May 28, 2013 · 3 revisions

From https://groups.google.com/d/msg/mathjax-users/hgNd79hdetQ/Uwej8Tly4WoJ to https://groups.google.com/d/msg/mathjax-users/dHcD4jSRbZ0/NqOtgrjpij8J


Hi,

I have a section on my project where I load an aspx page using jquery like in

$('#divexample').load("/MathjaxTesting.aspx");

The page I want to load has Mathml included but it cannot be displayed unless it is loaded as a result of a postback. Is there a way I can force rendering of the mathml without a postback?

Thank you.


You need to be careful about the synchronization of the MathJax actions and the jQuery load action. You need to be sure that the MathJax typeset call does not occur until after the jQuery load is complete. It is not clear where you have put the code MathJax.Hub.Queue command that you listed, but it should be part of a callback for the jQuery load command, as in:

$('#divexample').load("/MathjaxTesting.aspx", function () {
  MathJax.Hub.Queue(["Typeset",MathJax.Hub,"divexample"]);
});

The incorrect way would be

$('#divexample').load("/MathjaxTesting.aspx");
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"divexample"]);

since the contents of the divexample element might not have been loaded yet when the MathJax.Hub.Typeset command is performed. It might work, depending on the timing of the load, and the contents of you cache, but there is no guarantee, and it may well not work for some or all of your readers.

Davide

Clone this wiki locally