Mathjax无法从PHP/Ajax动态呈现TEX公式 [英] Mathjax not rendering TEX formulas dynamically from PHP/Ajax

查看:78
本文介绍了Mathjax无法从PHP/Ajax动态呈现TEX公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var questions = {"ques_id":"1","question":"<p><span class=\\\"math-tex\\\">\\\\(x = {-b \\\\pm \\\\sqrt{b^2-4ac} \\\\over 2a}\\\\)<\/span>&nbsp; &nbsp;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>
	<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>
		<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请求中得到以下问题

I'm getting the following question from Ajax request

MathJax已正确配置,但MathJax无法呈现来自JSON的问题.该问题保存在MySQL数据库中,并由ajax请求获取.

MathJax is configured properly but the question coming from the JSON is not rendered by MathJax. The question are saved in MySQL database and are fetched by ajax request.

我尝试了一切,但仍然无法正常工作.请帮助

I tried everything but it still not working. Please help

推荐答案

在Json中,它添加了双斜杠.请删除它会解决您的问题.

From Json it added double slash. Plz remove that it will solve your problem.

这篇关于Mathjax无法从PHP/Ajax动态呈现TEX公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆