` reference pages for more
information about the valid methods of specifying a callback.
Creating a Callback Explicitly
==============================
When you call a method that accepts a callback, you usually pass it a
callback specification (like in the examples above), which *describes*
a callback (the method will create the actual `Callback` object, and
return that to you as its return value). You don't usually create
`Callback` objects directly yourself.
There are times, however, when you may wish to create a callback
object for use with functions that don't create callbacks for you.
For example, the ``setTimeout()`` function can take a function as its
argument, and you may want that function to be a method of an object,
and would run into the problem described in the previous section if
you simply passed the object's method to ``setTimeout()``. Or you
might want to pass an argument to the function called by
``setTimeout()``. (Altough the ``setTimeout()`` function can accept
additional arguements that are supposed to be passed on to the code
when it is called, some versions of Internet Explorer do not implement
that feature, so you can't rely on it.) You can use a `Callback`
object to do this, and the :meth:`MathJax.Callback()` method will
create one for you. For example,
.. code-block:: javascript
function f(x) {alert("x = "+x)}
setTimeout(MathJax.Callback([f,"Hello World!"]),500);
would create a callback that calls ``f("Hello World!")``, and
schedules it to be called in half a second.
mathjax-docs-2.7+20171212/advanced/debugging-tips.rst 0000644 0000000 0000000 00000003437 13213762601 016744 0 ustar .. _debugging-tips:
**********************
MathJax Debugging tips
**********************
This page documents basic tips for debugging MathJax in your application.
Using unpacked resources
========================
MathJax provides both packged (minified) and unpacked versions of all its components. For debugging, it is useful to switch to an unpacked versions.
For example, if your copy of MathJax lives at `https://example.com/MathJax.js` just add `unpacked/` before `MathJax.js`, e.g.,
.. code-block:: html
to
.. code-block:: html
Getting traceback information
=============================
.. code-block:: javascript
MathJax.Hub.lastError
MathJax stores the error object from the last `Math Processing Error` in `MathJax.Hub.lastError`. This allow developers to access the stack trace information when needed.
Add listener for MathJax errors
===============================
MathJax provides a detailed signaling infrastructure which a developers can hook into.
The following example hooks into Math Processing Errors.
.. code-block:: javascript
MathJax.Hub.Register.MessageHook("Math Processing Error",function (message) {
// do something with the error. message[2] is the Error object that records the problem.
});
Another example hooks into TeX parsing errors.
.. code-block:: javascript
MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
// do something with the error. message[1] will contain the data about the error.
});
.. note::
For more information, see :ref:`mathjax-api`.
mathjax-docs-2.7+20171212/advanced/dynamic.rst 0000644 0000000 0000000 00000014425 13213762601 015457 0 ustar .. _ajax-mathjax:
***************************
Loading MathJax Dynamically
***************************
MathJax is designed to be included via a ``
TeX: \(\frac a b\)
MathML:
AsciiMath: `a^2 + b^2 = c^2`