首页 > 其他分享 >ECM5 Fetch

ECM5 Fetch

时间:2022-10-14 11:11:56浏览次数:53  
标签:xmlRequest function log 235767 pexels ECM5 Fetch imgURL

<html>
<body>
    <button onclick="fetchImage()">Fetch</button>
    <button onclick="ajaxRequest()">Ajax</button>
    <button onclick="ajaxRequest2()">Ajax2</button>
    <script type="text/javascript">
        "use strick";
        const imgURL="https://images.pexels.com/photos/235767/pexels-photo-235767.jpeg?cs=srgb&dl=pexels-pixabay-235767.jpg&fm=jpg&w=640&h=427";
        let fetchImage= async()=>{
            var myImageResponse= await fetch(imgURL);
            console.log("Image response:\n",myImageResponse.blob());
        }
        function ajaxRequest(){
            function reqListener(){
                console.log(this.response);
            }
            var xmlRequest=new XMLHttpRequest();
            xmlRequest.addEventListener("load",reqListener.bind(xmlRequest));
            xmlRequest.open("GET",imgURL);
            xmlRequest.send();
        }
        
        function ajaxRequest2(){
            
            var xmlRequest=new XMLHttpRequest();
            xmlRequest.open("GET",imgURL);
            xmlRequest.send();
            xmlRequest.onload=function(e){
                console.log(xmlRequest.response);
            }
        }
    </script>
</body>
</html>

 

标签:xmlRequest,function,log,235767,pexels,ECM5,Fetch,imgURL
From: https://www.cnblogs.com/jchblog/p/16790970.html

相关文章

  • ECM5 asynchronous
    <scripttype="text/javascript">"usestrick";letregularFunction=()=>{return"Hello";}lettimeoutFunction=msg=>{varreturnMsg;setTimeout((......
  • JS 调用 FetchXML
    varcurUserid=Xrm.Utility.getGlobalContext().userSettings.userId;varfetchXml="<fetchversion='1.0'output-format='xml-platform'mapping='logical'dis......
  • sqlserver 分页 row_number() over(), offset fetch next only
    1-row_number()over()  1declare@pageIndexint=1,@pageSize=102select*from(3selectROW_NUMBER()over(orderbyId)'rowid',count(*)over()'Tot......
  • ajax--fetch--axios
    //基本用法无参数get请求$.ajax({url:"demo_test.txt",success:function(result){console.log(result);}}//需指定方法则增加method字段$.......
  • screenfetch—最炫酷的查看你的设备信息
    screenfetch是一个很方便的并且很炫酷的一个程序,它可以做到很炫酷的输出你想要看到的系统信息。只需要短短一行命令,就可以快速的安装上它。!并且可以直观的显示出来,当前......
  • Fetch and axios
       ......
  • 【Linux】Unable to fetch some archives, maybe run apt-get update or try with --f
    一、问题描述在aptinstall时候遇到E:Unabletofetchsomearchives,mayberunapt-getupdateortrywith--fix-missing?的error。Error报的信息显示是这个包向so......
  • 请求 blob 图像并使用 fetch API 转换为 base64
    通用功能:functionurlContentToDataUri(url){returnfetch(url).then(response=>response.blob()).then(blob=>newPromise(cal......
  • Fetch发送请求 + 解决跨域问题
         解决跨域问题:fetch()方法提供了一种简单,合理的方式来跨网络异步获取资源。可以使用fetch向服务器发送get请求或post请求来获取数据fetch的基本用法:fetc......
  • fetch 获取图片视频资源
    前端获取cdn上资源时,如果cdn资源更新,前端 img、video等标签获取资源大概率会命中本地缓存资源那么如何能够更新这些资源呢,让页面显示新的资源呢,(指在不做强制刷新,关闭浏......