YangYoona 2017-07-31 12:07 采纳率: 5.6%
浏览 1406
已采纳

html5 ajax 访问百度云接口的问题

<!DOCTYPE html>



title here ajax





a
<br> function show(){<br> CreateXmlHttp();<br> if(!xhr){<br> alert(&quot;创建xmlhttp对象异常&quot;);<br> return false;<br> }<br> xhr.open(&quot;POST&quot;, &quot;<a href="https://aip.baidubce.com/oauth/2.0/token%22">https://aip.baidubce.com/oauth/2.0/token&quot;</a>);<br> xhr.setRequestHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;);<br> xhr.onreadystatechange = function () {<br> if(xhr.readyState == 4){<br> document.getElementById(&quot;dd&quot;).innerHTML = &quot;数据正在加载。。。&quot;+xhr.status;<br> if(xhr.status == 200){<br> document.getElementById(&quot;write&quot;).innerHTML = xhr.responseText;<br> }else{<br> document.getElementById(&quot;write&quot;).innerHTML = &quot;不能够进行跨域请求。&quot;;<br> }<br> }<br> }</p> <pre><code> xhr.send(&#39;grant_type=client_credentials&amp;client_id=mfnwFRuO5EOewQON0piojoNR&amp;client_secret=3aDW6TU1nZ7mDsAx5zjvz75WPVyx6LeG&#39;); } function CreateXmlHttp(){ //非IE浏览器创建XmlHttpRequest对象 if(window.XMLHttpRequest){ xhr = new XMLHttpRequest(); } //IE浏览器创建XmlHttpRequest对象 if(window.ActiveXObject){ try{ xhr = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); }catch(e){ try{ xhr = new ActiveXObject(&quot;msxml2.XMLHTTP&quot;); }catch(ex){ } } } } &lt;/script&gt; &lt;/body&gt; </code></pre> <p></html></p> <p>这是代码,大神门看一看怎么改浏览器就都能访问啦,手机上也需要能访问,现在只有IE浏览器能访问</p>
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 如何关闭soui dummy wdn 进程
      • ¥20 含有jar文件的文件夹用tar -zcvf 命令压缩后要怎么还原回去?
      • ¥15 天宝TBC软件出现报错怎么解决
      • ¥15 micropython 从1开始切片报错
      • ¥15 请问该怎么做才能将文字说明和二维码一起作为png图片一起下载
      • ¥15 r语言 混频数据回归 midas_r
      • ¥15 人脸识recogizer.predict返回值id报错,KeyError,详情如下
      • ¥15 geowebcache部署失败
      • ¥20 关于adaboost+haar特征实现人脸检测过程的一些细节问题
      • ¥15 csv文件增加一列 为csv文件的名字