首页 > Web开发 > 详细

you might not need jquery

时间:2019-08-06 14:56:53      阅读:101      评论:0      收藏:0      [点我收藏+]

What‘s the oldest version of IE you need to support? IE10

 

 1 /**json**/
 2 var request = new XMLHttpRequest();
 3 request.open(‘GET‘, ‘/my/url‘, true);
 4 
 5 request.onload = function() {
 6   if (this.status >= 200 && this.status < 400) {
 7     // Success!
 8     var data = JSON.parse(this.response);
 9   } else {
10     // We reached our target server, but it returned an error
11 
12   }
13 };
14 
15 request.onerror = function() {
16   // There was a connection error of some sort
17 };
18 
19 request.send();

 

 1 /**request**/
 2 var request = new XMLHttpRequest();
 3 request.open(‘GET‘, ‘/my/url‘, true);
 4 
 5 request.onload = function() {
 6   if (this.status >= 200 && this.status < 400) {
 7     // Success!
 8     var resp = this.response;
 9   } else {
10     // We reached our target server, but it returned an error
11 
12   }
13 };
14 
15 request.onerror = function() {
16   // There was a connection error of some sort
17 };
18 
19 request.send();

 

1 /**post**/
2 var request = new XMLHttpRequest();
3 request.open(‘POST‘, ‘/my/url‘, true);
4 request.setRequestHeader(‘Content-Type‘, ‘application/x-www-form-urlencoded; charset=UTF-8‘);
5 request.send(data);

 

/**hide**/
el.style.display = ‘none‘;

 

 1 /**fade in**/
 2 /**javascript**/
 3 <script>
 4     el.classList.add(show);
 5     el.classList.remove(hide);
 6 </script>
 7 <style>
 8     .show {
 9       transition: opacity 400ms;
10     }
11     .hide {
12       opacity: 0;
13     }
14 </style>

 

/**show**/
el.style.display = ‘‘;

 

/**add class**/
el.classList.add(className);

 

/**after**/
el.insertAdjacentHTML(‘afterend‘, htmlString);

 

/**append**/
parent.appendChild(el);

 

/**before**/
el.insertAdjacentHTML(‘beforebegin‘, htmlString);

 

/**clone**/
el.cloneNode(true);

 

/**contains**/
el !== child && el.contains(child);

 

you might not need jquery

原文:https://www.cnblogs.com/qixianchuan/p/11308792.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!