<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS</title>
    <style>
        #box{
            width:600px;
            height:200px;
            padding:20px;
            border:1px solid #999;
        }
    </style>
    
</head>
<body>
    <h1>ajax跨域请求操作实例</h1>
    <hr>
    <button onclick="loadHtml()">加载</button>
    <div ></div>
    <script>
        //http://127.0.0.1/s32/JS10_Jquery01/lessson/2.php
        function loadHtml(){
            //创建script
            var script = document.createElement("script");
            script.src = "http://127.0.0.1/s32/JS10_Jquery01/lessson/2.php";
            //把script元素追加到body
            document.body.appendChild(script);
            //删除
            document.body.removeChild(script);
        }
        
        //定义函数
        function addHtml(data){
            document.getElementById('box').innerHTML = data;
        }
    </script>
</body>
</html>

 

相关文章:

  • 2022-01-23
  • 2021-05-29
  • 2021-10-23
猜你喜欢
  • 2022-12-23
  • 2021-12-19
  • 2021-12-19
  • 2021-03-31
  • 2021-05-30
  • 2021-07-31
相关资源
相似解决方案