码迷,mamicode.com
首页 > 移动开发 > 详细

HBuilder开发app ajax跨域 解决XMLHttpRequest

时间:2016-08-18 19:41:04      阅读:429      评论:0      收藏:0      [点我收藏+]

标签:

<div id="a1" onclick="testXHR()" style="font-size: 5em;">sss1</div>

  <script type="text/javascript">
          var data;
          var xhr=null;          
          function testXHR(){
              if(xhr){
                  return;
              }
              xhr=new plus.net.XMLHttpRequest();
              xhr.onreadystatechange=xhrStatechange;
              xhr.open( "GET", url);
              xhr.send();
          }
          function xhrStatechange(){
              if (xhr.readyState==4&&xhr.status == 200) {
                   
               
                      data = JSON.parse(xhr.responseText);
                   
                       
                   
            
                           
                      //alert(data.a1)   
                      for(i in data){alert(data[i])}
                                              
               
              }
          }
           
</script>

HBuilder开发app ajax跨域 解决XMLHttpRequest

标签:

原文地址:http://www.cnblogs.com/sjd1118/p/5785067.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!