The div passed through ajax does not have the original effect.

Source: Internet
Author: User
Tags string to json
The div passed through ajax does not have the original effect.
$ Table ="

<>

"; $ Result = array ('table' => $ table); echo json_encode ($ result );


This is an image to enlarge the display effect. it's okay if I put it on the page directly, but those effects won't work if I pass it through ajax.


Reply to discussion (solution)

How is your js code written? You can check whether an error is returned on the console.

How js obtains and displays json data on the server.

$ ('Your container element'). append ($ ('json data returned by the server, it should be html tag content ').

This is a bit superfluous. why do you need to convert a string to json. Can it be returned directly.
1. php

$ Table ="

<>

"; Echo $ table;

$. Get ('1. php', function (data) {$ ("parent container"). append (data );})

Your current code does not work either when you get the json value or when some special characters are escaped, even if the page is correctly retrieved, it is not parsed.
However, we recommend that you directly return the string
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.