Jquery进度条

来源:互联网 发布:网站流量统计java代码 编辑:程序博客网 时间:2024/06/04 00:52

Jquery我基本不用的,只会基本API,我一般都是用原生的写。

<body><div class="box"><div class="content"></div></div><script type="text/javascript" src="jquery-3.1.1.js"></script><script type="text/javascript">var num=50;$(".content").css("width",num+"%");</script></body>

定位什么就不写了。就这样的直接改他的宽度。  我真不知道还能怎么写。


后台获取数据修改宽度。

AJAX简单实现:

由于可能会出现跨域的情况,所以使用了jsonp

 但是  我也知道为什么还是跨域了.

                         

$.ajax({ type : "get", async:false, url : "./1.txt",     dataType : "jsonp",//jsonp数据类型     jsonp: "jsonpCallback",//服务端用于接收callback调用的function名的参数     success : function(data){     $(".content").css("width",data+"%")     },     error:function(){     alert('fail');     } }); 


解决跨域问题

window.domain   jsonp      


原生ajax:

var xhr=new XMLHTTPRequest();


xhr.onreadystatechange=function(){

if((xhr.status==200&&readystatus==4){

alert(xhr.responseText);

}

}

 xhr.open("get","./1.txt"); 

xhr.send(null);




readystates:

0:未初始化  no open

1:启动    open no send

2:发送   send no response

3:接受  response no finished

4:完成   finished


响应之前取消ajax  xhr.abort();




 我也不知道我在干什么。今天就这样吧。





原创粉丝点击