weixin_33722405 2014-06-11 02:42 采纳率: 0%
浏览 208

如何在Ajax中使用MAthjax

Good morning, how can render div with mathjax after ajax data is inserted into it? I have read some posts but could not find :(. It is working only one time. second and third time not working. I have tried also to put

   MathJax.Hub.Queue(["Typeset",MathJax.Hub, "test"]);

after and before ajax insertion.

$this->widget('bootstrap.widgets.TbButton', array(
'htmlOptions'   => array('id'=> 'start'),
'buttonType'=>'ajaxButton',
'type'=>'primary',
'label'=>'Start',
'url'=>CController::createUrl('site/next'),
'ajaxOptions'=>array(
    'type'=>'post',
    'data'=>array('row'=>$row),
    'success'=>'function(data){
           $("#test").html(data);
                MathJax.Hub.Queue(["Typeset",MathJax.Hub, "test"]);             
    }'  )

));

  • 写回答

1条回答 默认 最新

  • weixin_33743703 2014-06-12 06:09
    关注

    I don't think its a specific MathJax issue. The following code creates a a one line input form and dynamically takes the mathml code in it and renders that with mathjax. This works fine with repeated inputs, so the MathJax.Hub.Queue(["Typeset",...) part works fine. Try adding an alert(data) in your ajax code to check you are being given the correct input from ajax.

    <!doctype html>
    <html>
    <head>
    <title>Creating mathml from expressions</title>
    
    <script src="../MathJax/MathJax.js">
      MathJax.Hub.Config({
        extensions: ["mml2jax.js"],
        jax: ["input/MathML","output/HTML-CSS"]
      });
    </script>
    
    <script type="text/javascript">
    <!--
    function render()
    {
      var res = document.getElementById('equation').value;
      alert(res);
      var target = document.getElementById('outputDiv');
      target.innerHTML=res;
      MathJax.Hub.Queue(["Typeset",MathJax.Hub,'outputDiv']);
    }
    // -->
    </script>
    </head>
    <body>
    <h1>MathML to MathJax<h1>
    
    <form>
    <input type="text" id="equation" size="100" value="<math><msup><mi>x</mi><mn>2</mn>    </msup></math>"/> 
    <input type="button" value="Render" onClick="render();"/>
    </form>
    
    <div id="outputDiv" style="border:1px; font-size:x-large;">
    
    </div>
    </body>
    </html>
    
    评论

报告相同问题?

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择