Mathjax不能从PHP / Ajax动态渲染TEX公式

时间:2017-06-03 16:31:39

标签: php jquery ajax dynamic mathjax

<!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>
ALTER PROCEDURE [dbo].[BookUpdate]
    @Name nvarchar(max),
    @BookId int,
    @PublishingHouse nvarchar(255),
    @PublicationYear smallint,
    @Authors nvarchar(255),
    @Description nvarchar(max),
    @BookShelf int,
    @UserId int,
    @Cover varbinary(max),
    @Id int OUT
AS
BEGIN
    DECLARE @haveDouble int = 0
    DECLARE @haveUser int = 1

    SELECT @haveDouble = Id 
    FROM dbo.Books 
    WHERE Name = @Name 
      AND Authors = @Authors  
      AND PublicationYear = @PublicationYear 
      AND Id != @BookId

    IF @UserId > 0
    BEGIN
        SELECT @haveUser = UserId 
        FROM dbo.Users 
        WHERE UserId = @UserId
    END

    SET @Id = 0

    IF @haveDouble = 0 AND @haveUser > 0
    BEGIN
        UPDATE dbo.Books
        SET [Name] = @Name,
            [PublishingHouse] = @PublishingHouse,
            [PublicationYear] = @PublicationYear,
            [Authors] = @Authors,
            [Description] = @Description,
            [BookShelf] = @BookShelf,
            [Cover] = @Cover,
            [UserId] = @UserId
        WHERE
            Id = @BookId

        SET @Id = @BookId
    END     
END

我从Ajax请求中得到以下问题

MathJax已正确配置,但来自JSON的问题未由MathJax呈现。问题保存在MySQL数据库中,并由ajax请求提取。

我尝试了一切,但它仍无法正常工作。请帮忙

1 个答案:

答案 0 :(得分:2)

来自Json,它增加了双斜线。 Plz删除它将解决您的问题。