Search code examples
ajaxmathjax

Using Mathjax in ajax call


A question related to Mathjax not working in Ajax based web page

Maybe a stupid question, but where do I have to add this?

I've added

<script>MathJax.Hub.Queue(["Typeset",MathJax.Hub]);</script>

to the page I load with Ajax, but the MathJax is still not loading.

On the main page I've added the script below, and it is working fine.

<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

Solution

  • In order to typeset the MathJax after the page has loaded already, you should call the MathJax.typeset() function or the MathJax.typesetPromise() if you want to use promises. Make sure you call the above function only after the AJAX has loaded into your page.

    See the docs for rendering dynamic content for a more detailed explanation.