<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          httpx.jsHTTP/RESTful 請求庫

          聯(lián)合創(chuàng)作 · 2023-09-19 07:45

          httpx.js 是一個簡單的  JavaScript HTTP/RESTful 請求庫。

          主要方法

          • GET

          • POST

          • PUT

          • PATCH

          • DELETE

          • Other

          • JSON

          • JSONP

          • getScript

          兼容情況

          • Firefox 4.0+

          • Chrome 7+

          • IE 9+

          • Opera 11.60+

          • Safari 5.1.4+

          使用方法

          get|post|put|patch|delete|json(alias getJSON)(url, [data], [callback], [error]);

          GET:

          httpx.get("http://localhost/http-test/get.php?foo=Level1&bar=XHR&zh=中文", function(data) {
              console.log(data, this);
          }, function(method, url) {
              console.error("Custom Error", method, url, this.status, this.statusText);
          });

          POST:

          httpx.post("http://localhost/http-test/post.php?edfd=eedfd&dfsdf=ere", {
              a : 12,
              b : "bbbb",
              c : 123489
          }, function(data) {
              console.log(data, this);
          });

          PUT:

          httpx.put("http://localhost/http-test/put.php?edfd=eedfd&dfsdf=ere", {
              a : 12,
              b : "bbbb",
              c : 123489
          }, function(data) {
              console.log(data, this);
          });

          DELETE:

          httpx.delete("http://localhost/http-test/delete.php?edfd=eedfd&dfsdf=ere", {
              a : 12,
              b : "bbbb",
              c : 123489
          }, function(data) {
              console.log(data, this);
          });

          JSON(getJSON):

          // Alias getJSON(), like jQuery
          httpx.json("http://localhost/http-test/get-json.php?temp="+(new Date).getTime(), {
              test : 123
          }, function(json) {
              console.log("get json =>", json);
          });

          JSONP:

          //jsonp(url, [data], [callback], [callbackName]); // callbackName for query string name
          
          httpx.jsonp("http://192.168.1.2/http-test/jsonp.php?temp="+(new Date).getTime(), {
              test : 123
          }, function(json) {
              console.log("jsonp =>", json);
          }, "callback");

          getScript:

          httpx.getScript("http://192.168.1.2/http-test/test.js", function() {
              test();
          });

          選項

          {
              async         : true,
              timeout       : 3000,
              method        : "GET",
              url           : "",
              data          : "",
              dataType      : "text",
              headers       : {},
              contentType   : "text/plain; charset=UTF-8",
              jsonp         : "callback",    // for query string
              success       : function() {},
              error         : function(method, url) {},
              ontimeout     : function(method, url) {}
          }
          httpx.request({
              url : "http://localhost/http-test/head.php",
              method : "HEAD",  // Custom http method
              headers : {},  // Custom http headers
              success : function(data) {
                  console.log(data);
              }
          });
          
          httpx.get({
              url : "http://localhost/http-test/get.php?foo=bar",
              headers : {
                  "xxxxxxx" : "xxxxx"
              },
              success : function(data) {
                  console.log(data);
              }
          });
          
          httpx.post({
              url : "http://localhost/http-test/post.php?foo=bar",
              data : {
                  id : 123,
                  title : "xxxxx"
              },
              headers : {
                  "xxxxxxx" : "xxxxx"
              },
              success : function(data) {
                  console.log(data);
              }
          });
          
          // put/patch/delete/json ...
          瀏覽 16
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  香蕉午夜视频 | 色婷婷综合视频在线观看 | 婷婷色五月天丁香 | 国产精品在线免费观看 | 欧美 第一页 |