<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>

          Reqwest瀏覽器異步HTTP請(qǐng)求

          聯(lián)合創(chuàng)作 · 2023-09-21 16:30

          reqwest 用于瀏覽器異步HTTP請(qǐng)求。支持xmlHttpRequest, JSONP, CORS, 和 CommonJS約束。

          API

          reqwest('path/to/html', function (resp) {
            qwery('#content').html(resp)
          })
          
          reqwest({
              url: 'path/to/html'
            , method: 'post'
            , data: { foo: 'bar', baz: 100 }
            , success: function (resp) {
                qwery('#content').html(resp)
              }
          })
          
          reqwest({
              url: 'path/to/html'
            , method: 'get'
            , data: [ { name: 'foo', value: 'bar' }, { name: 'baz', value: 100 } ]
            , success: function (resp) {
                qwery('#content').html(resp)
              }
          })
          
          reqwest({
              url: 'path/to/json'
            , type: 'json'
            , method: 'post'
            , error: function (err) { }
            , success: function (resp) {
                qwery('#content').html(resp.content)
              }
          })
          
          reqwest({
              url: 'path/to/json'
            , type: 'json'
            , method: 'post'
            , contentType: 'application/json'
            , headers: {
                'X-My-Custom-Header': 'SomethingImportant'
              }
            , error: function (err) { }
            , success: function (resp) {
                qwery('#content').html(resp.content)
              }
          })
          
          // Uses XMLHttpRequest2 credentialled requests (cookies, HTTP basic auth) if supported
          reqwest({
              url: 'path/to/json'
            , type: 'json'
            , method: 'post'
            , contentType: 'application/json'
            , crossOrigin: true
            , withCredentials: true
            , error: function (err) { }
            , success: function (resp) {
                qwery('#content').html(resp.content)
              }
          })
          
          reqwest({
              url: 'path/to/data.jsonp?callback=?'
            , type: 'jsonp'
            , success: function (resp) {
                qwery('#content').html(resp.content)
              }
          })
          
          reqwest({
              url: 'path/to/data.jsonp?foo=bar'
            , type: 'jsonp'
            , jsonpCallback: 'foo'
            , jsonpCallbackName: 'bar'
            , success: function (resp) {
                qwery('#content').html(resp.content)
              }
          })
          
          reqwest({
              url: 'path/to/data.jsonp?foo=bar'
            , type: 'jsonp'
            , jsonpCallback: 'foo'
            , success: function (resp) {
                qwery('#content').html(resp.content)
              }
            , complete: function (resp) {
                qwery('#hide-this').hide()
              }
          })

          約束

          reqwest({
              url: 'path/to/data.jsonp?foo=bar'
            , type: 'jsonp'
            , jsonpCallback: 'foo'
          })
            .then(function (resp) {
              qwery('#content').html(resp.content)
            }, function (err, msg) {
              qwery('#errors').html(msg)
            })
            .always(function (resp) {
              qwery('#hide-this').hide()
            })
          
          reqwest({
              url: 'path/to/data.jsonp?foo=bar'
            , type: 'jsonp'
            , jsonpCallback: 'foo'
          })
            .then(function (resp) {
              qwery('#content').html(resp.content)
            })
            .fail(function (err, msg) {
              qwery('#errors').html(msg)
            })
            .always(function (resp) {
              qwery('#hide-this').hide()
            })
          
          var r = reqwest({
              url: 'path/to/data.jsonp?foo=bar'
            , type: 'jsonp'
            , jsonpCallback: 'foo'
            , success: function () {
                setTimeout(function () {
                  r
                    .then(function (resp) {
                      qwery('#content').html(resp.content)
                    }, function (err) { })
                    .always(function (resp) {
                       qwery('#hide-this').hide()
                    })
                }, 15)
              }
          })

          支持的瀏覽器

          • IE6+

          • Chrome 1+

          • Safari 3+

          • Firefox 1+

          • Opera

          瀏覽 9
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <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>
                  日韩天堂一区 | 狠狠狠狠干 | 亚洲欧美国产高清vA在线播放 | 青青草视频成人动漫视频 | 国产一卡二卡三卡四卡在线观看 |