Javascript 如何让Mathjax.js与ANCII.js一起显示附加的json数据作为正确的公式?

Javascript 如何让Mathjax.js与ANCII.js一起显示附加的json数据作为正确的公式?,javascript,jquery,json,math,Javascript,Jquery,Json,Math,我正在做一个数学测验,并尝试使用json存储问题,使用Mathjax.js和ANSCII.js呈现复杂的数学表达式 比如说 { 我有一个附加问题数据的函数,比如 /MyLib.x是一个变量,它在问题数组中选择当前问题,并随着问题的进展而递增/ var choiceOne=$(“”).append('A.+$exam[MyLib.x].choices[0]); var choiceTwo=$(“”).append('B.+$exam[MyLib.x].choices[1]); var choice

我正在做一个数学测验,并尝试使用json存储问题,使用Mathjax.js和ANSCII.js呈现复杂的数学表达式

比如说 {

我有一个附加问题数据的函数,比如

/MyLib.x是一个变量,它在问题数组中选择当前问题,并随着问题的进展而递增/

var choiceOne=$(“”).append('A.+$exam[MyLib.x].choices[0]);
var choiceTwo=$(“”).append('B.+$exam[MyLib.x].choices[1]);
var choiceThree=$(“”).append('C.+$exam[MyLib.x].choices[2]);
var choicefur=$(“”).append('D.+$exam[MyLib.x].choices[3]);
var currentQuestion=$('').append($exam[MyLib.x].question);
$(“#options”).find('p').remove().hide();
$('#optionOne').fadeIn(250).append(choiceOne);
$('optionTwo').fadeIn(250).append(choiceTwo);
$('#optiontree').fadeIn(250).append(choiceThree);
$('#optionFour').fadeIn(250).append(choicefur);
但是当附加数据时,数据只显示了“”之间的内容,而不是希望的公式,我需要将其字符串化还是使用某种js方法?

找到了解决方案

MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
确保在追加文本后呈现文本

var choiceOne=$('<p>').append('A.'+$exam[MyLib.x].choices[0]);
var choiceTwo=$('<p>').append('B.'+$exam[MyLib.x].choices[1]);
var choiceThree=$('<p>').append('C.'+$exam[MyLib.x].choices[2]);
var choiceFour=$('<p>').append('D.'+$exam[MyLib.x].choices[3]);

var currentQuestion=$('<h3>').append($exam[MyLib.x].question);


$('#options').find('p').remove().hide();
$('#optionOne').fadeIn(250).append(choiceOne);
$('#optionTwo').fadeIn(250).append(choiceTwo);      
$('#optionThree').fadeIn(250).append(choiceThree);
$('#optionFour').fadeIn(250).append(choiceFour);
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);