I'm trying to use MathJax to convert text into mathematics while typing, using a textarea field. However when I send the typed text to a database to retrieve the text through a php file back to the original file, I can't get MathJax to convert the text into LaTeX-like symbols.
This is the main part (using jQuery):
$(document).ready(function(){
$('textarea').keydown(function(){
dynamic(); \\ A function described in MathJax documentation to load dynamically
var text = $('textarea').val();
$.post('process.php',{开发者_开发百科 input: text } );
$("#unload").load('fetch.php');
});
});
where dynamic() is defined as (taken from Loading MathJax Dynamically):
function dynamic(){var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://miql.zxq.net/MathJax/MathJax.js";
var config = 'MathJax.Hub.Config({ config: "MathJax.js" }); ' +
'MathJax.Hub.Startup.onload();';
if (window.opera) {script.innerHTML = config}
else {script.text = config}
document.getElementsByTagName("head")[0].appendChild(script);
};
Furthermore, I have the regular script to MathJax which works alright but uses an onload event.
I think I'm getting wrong the instructions to load MathJax dynamically. What is the correct way to do it? Any help will be greatly appreciate it.
It sounds like you want to modify math on the page. See http://www.mathjax.org/resources/docs/?typeset.html
Also see the demo page at http://mathjax.org/mathjax/test/sample-dynamic.html
精彩评论