D
D
den_novichok2022-03-24 07:05:17
AJAX
den_novichok, 2022-03-24 07:05:17

How to output value from ajax to html tag?

There is a php page in which the variable $p = 5 is written; $p = json_decode($p, true); I decode it so that it becomes understandable for java script and display it with a simple echo $p; the data is received in the content function, I checked it through alert, I want to place this content value in the content div, I will be grateful for the help, I have already read a lot of documentation, but I still don’t understand how to do it, I say right away this is not a form, but just a line
further in the Bak.html page

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"/>
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1" />

    <meta http-equiv="X-UA-Compatible" content="ie=edge" />

    <title>document</title>

    <script src="jquery.min.js"></script>

    <script type="text/javascript">
        $("document").ready(function () {

            setInterval(function (){
                getBak();
            }, 9000);

            function getBak() {


                $.ajax({
                    url: 'get.php',
                    type: 'POST',
                    success: function (content) {
                        $('.content').append(content);
                        alert(content);

                    }
                });
            }
        });

    </script>
</head>
<body>
<div id="content"></div>
<div class = "content"></div>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zagir Majidov, 2022-03-24
@Zagir-vip

$('.content').innerText = content

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question