3
var questions = {"ques_id":"1","question":"<p><span class=\\\"math-tex\\\">\\\\(x = {-b \\\\pm \\\\sqrt{b^2-4ac} \\\\over 2a}\\\\)<\/span> Test Question new with mathjax<\/p>","ques_type":"text_based_questions","correctAnswer":3,"choices":[{"option_id":"1","value":"Option A"},{"option_id":"2","value":"Option B"},{"option_id":"3","value":"Option C"},{"option_id":"4","value":"OPtion D"}]};
$('#test-question').html(questions.question);
MathJax.Hub.Queue(["Typeset",MathJax.Hub, 'test-question']);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showProcessingMessages: false,
tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] }
});
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_HTMLorMML">
</script>
</head>
\t <body>
<h5 class="border-bottom">Instructions: Read the question, work out your answer and select the best option.</h5>
<p><span class="math-tex">\(\left(\sum_{k=1}^n a_k b_k \right)^2 \leq \left(\sum_{k=1}^n a_k^2 \right) \left(\sum_{k=1}^n b_k^2 \right) \)</span></p>
\t \t <div class="question" id="test-question"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</body>
</html>
我從Ajax請求得到以下問題
MathJax配置正確,但來自JSON來的問題是不會呈現由MathJax提供。這個問題保存在MySQL數據庫中,並通過ajax請求獲取。
我嘗試了一切,但它仍然無法正常工作。請幫助
您可能想要使用片段功能創建實例。這很可能是一個簡單的同步問題,但沒有足夠的信息。 –
@PeterKrautzberger我已經添加了一個代碼片段,其中MathJax從JSON未呈現。 –