テキストエリアフィールドを使用して、入力中にテキストを数学に変換するためにMathJaxを使用しようとしています。ただし、入力したテキストをデータベースに送信して、php ファイルを介して元のファイルにテキストを取得すると、MathJax でテキストを LaTeX のような記号に変換できません。
これが主要部分です (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');
});
});
ここで、dynamic() は次のように定義されます ( 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);
};
さらに、問題なく動作しますが、onload イベントを使用する MathJax への通常のスクリプトがあります。
MathJax を動的にロードする手順が間違っていると思います。それを行う正しい方法は何ですか?どんな助けでも大歓迎です。