zoukankan      html  css  js  c++  java
  • js-ajax-02

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        <input type="button" name="#" id="btn" value="请求">
        <script type="text/javascript" src="ajax.js"></script>
        <script type="text/javascript">
            // var oBtn=document.getElementById('btn');
            // oBtn.onclick=function(){
            //     ajax('a.txt',function(s){
            //         console.log(s);
            //     },function(){
            //         alert("请求发生错误");
            //     })
            // }
    
    //以上代码  console.log  出来的内容是  aa.txt里的内容   这是ajax请求得到的东西1
    
    
        var oBtn=document.getElementById('btn');
        oBtn.onclick=function(){
            ajax('arr.txt',function(s){
                console.log(s);
                var arr=eval(s)//把扔回来的东西,变成数组
                var newStr='';
                for(var i=0;i<arr.length;i++){
                    newStr+=arr[i];
                }
                console.log(newStr);
    
            },function(){
                alert('请求发生了错误');
            })
        }
    
    
    
    
    
    
    
    
    
        </script>
    </body>
    </html>
  • 相关阅读:
    STM32概述
    对xlslib库与libxls库的简易封装
    Makefile.am编写规则
    linux下使用autoconf制作Makefile
    python 登录三次禁止登录
    Linux -- gpasswd
    Linux -- userdel
    Linux -- groupmod
    Linux -- groupadd
    Linux -- passwd
  • 原文地址:https://www.cnblogs.com/jinsuo/p/7890009.html
Copyright © 2011-2022 走看看