File tree Expand file tree Collapse file tree 5 files changed +28
-6
lines changed
Expand file tree Collapse file tree 5 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 1313< script src ="./server.js "> </ script >
1414< script >
1515 var data = {
16- // url: encodeURIComponent(window.location.href)
17- a : 1 ,
18- b : 2 ,
19- c : 3
16+ url : encodeURIComponent ( window . location . href )
17+ // a: 1,
18+ // b: 2,
19+ // c: 3
2020 } ;
2121 ajax ( {
2222 data : data ,
2323 url : 'https://h5.kankanapp.com.cn/wechatapi/' ,
24- // dataType: 'jsonp',
25- type : 'post ' ,
24+ dataType : 'jsonp' ,
25+ type : 'get ' ,
2626 done : function ( json ) {
2727 console . log ( JSON . stringify ( json ) ) ;
2828 }
Original file line number Diff line number Diff line change @@ -74,11 +74,21 @@ function ajax(opts) {
7474 window [ callbackName ] = function ( json ) {
7575 oHead . removeChild ( oScript ) ;
7676 window [ callbackName ] = null ;
77+ window . clearTimeout ( oScript . timer ) ;
7778 opts . success && opts . success ( json ) ;
7879 opts . done && opts . done ( json ) ;
7980 } ;
8081
8182 //发起请求
8283 oScript . src = opts . url + '?' + params ;
84+
85+ if ( opts . time ) {
86+ oScript . timer = window . setTimeout ( function ( ) {
87+ oHead . removeChild ( oScript ) ;
88+ window [ callbackName ] = null ;
89+ opts . fail && opts . fail ( { message : 'timeout' } ) ;
90+ opts . done && opts . fail ( { message : 'timeout' } ) ;
91+ } , opts . time ) ;
92+ }
8393 }
8494}
Original file line number Diff line number Diff line change 1+ ### Usage
2+
3+ ```
4+ init:
5+ var wtf = new WaterFull('.content', {
6+ type: listType,
7+ urlField: 'picUrl'
8+ });
9+
10+ create:
11+ wtf.create(dataArr);
12+ ```
You can’t perform that action at this time.
0 commit comments