All Projects → ded → Reqwest

ded / Reqwest

browser asynchronous http requests

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
Makefile
30231 projects

Projects that are alternatives of or similar to Reqwest

Dotnetdesk
Asp.Net Example web application showing the capabilities of ASP.NET Core 2 MVC, EF (Entity Framework), Web API, Bootstrap, jQuery, datatables, adminlte template and many more. Web app created as helpdesk or ticket support portal.
Stars: ✭ 136 (-95.34%)
Mutual labels:  ajax, jquery
Featherlight
Featherlight is a very lightweight jQuery lightbox plugin. It's simple yet flexible and easy to use. Featherlight has minimal css and uses no inline styles, everything is name-spaced, it's completely customizable via config object and offers image, ajax and iframe support out of the box. Featherlights small footprint weights about 4kB – in total.
Stars: ✭ 2,037 (-30.19%)
Mutual labels:  ajax, jquery
Jquery Confirm
A multipurpose plugin for alert, confirm & dialog, with extended features.
Stars: ✭ 1,776 (-39.14%)
Mutual labels:  ajax, jquery
Django Crud Ajax Login Register Fileupload
Django Crud, Django Crud Application, Django ajax CRUD,Django Boilerplate application, Django Register, Django Login,Django fileupload, CRUD, Bootstrap, AJAX, sample App
Stars: ✭ 118 (-95.96%)
Mutual labels:  ajax, jquery
Ajax Live Search
AJAX Live Search is a PHP search form that similar to Google Autocomplete feature displays the result as you type.
Stars: ✭ 238 (-91.84%)
Mutual labels:  ajax, jquery
Klik Socialmediawebsite
Complete PHP-based Login/Registration system, Profile system, Chat room, Forum system and Blog/Polls/Event Management System.
Stars: ✭ 129 (-95.58%)
Mutual labels:  ajax, jquery
Nette.ajax.js
Flexible AJAX for Nette Framework. Supports snippets, redirects etc.
Stars: ✭ 150 (-94.86%)
Mutual labels:  ajax, jquery
Bpage
Based on bootstrap style, static page jump can also be asynchronous page processing pagination plugin
Stars: ✭ 96 (-96.71%)
Mutual labels:  ajax, jquery
Bbs Ssm
南生论坛基于SSM框架,自适应手机端和电脑端,界面简洁美观,功能完善。演示地址:http://www.nanshengbbs.top
Stars: ✭ 221 (-92.43%)
Mutual labels:  ajax, jquery
Bs grid
Bootstrap Datagrid
Stars: ✭ 184 (-93.69%)
Mutual labels:  ajax, jquery
Nukeviet
NukeViet CMS is multi Content Management System. NukeViet CMS is the 1st open source content management system in Vietnam. NukeViet was awarded the Vietnam Talent 2011, the Ministry of Education and Training Vietnam officially encouraged to use.
Stars: ✭ 113 (-96.13%)
Mutual labels:  ajax, jquery
miniAjax
🚀A mini Ajax library provides Ajax, jsonp and ready features for simple web applications.
Stars: ✭ 67 (-97.7%)
Mutual labels:  ajax, jsonp
Fileuploader
Beautiful and powerful HTML file uploading tool. A jQuery, PHP and Node.js plugin that transforms the standard input into a revolutionary and fancy field on your page.
Stars: ✭ 111 (-96.2%)
Mutual labels:  ajax, jquery
Webapiclientgen
Strongly Typed Client API Generators generate strongly typed client APIs in C# .NET and in TypeScript for jQuery and Angular 2+ from ASP.NET Web API and .NET Core Web API
Stars: ✭ 134 (-95.41%)
Mutual labels:  ajax, jquery
Formchimp
A customizable MailChimp ajax plugin for jQuery
Stars: ✭ 98 (-96.64%)
Mutual labels:  ajax, jquery
Jquery.initialize
jQuery plugin for dynamically created elements initialization (it was nice few years ago, in 2019+ consider react or sth instead of jQuery)
Stars: ✭ 150 (-94.86%)
Mutual labels:  ajax, jquery
Mydailylearn
🚀 Important commands, Code Snippets, Basics on different topics learning daily 🎉!
Stars: ✭ 87 (-97.02%)
Mutual labels:  ajax, jquery
Jeeplatform
一款企业信息化开发基础平台,拟集成OA(办公自动化)、CMS(内容管理系统)等企业系统的通用业务功能 JeePlatform项目是一款以SpringBoot为核心框架,集ORM框架Mybatis,Web层框架SpringMVC和多种开源组件框架而成的一款通用基础平台,代码已经捐赠给开源中国社区
Stars: ✭ 1,285 (-55.96%)
Mutual labels:  ajax, jquery
J2team Community
Join our group to see more
Stars: ✭ 172 (-94.11%)
Mutual labels:  ajax, jquery
Django Bootstrap Modal Forms
A Django plugin for creating AJAX driven forms in Bootstrap modal.
Stars: ✭ 244 (-91.64%)
Mutual labels:  ajax, jquery

It's AJAX

All over again. Includes support for xmlHttpRequest, JSONP, CORS, and CommonJS Promises A.

It is also isomorphic allowing you to require('reqwest') in Node.js through the peer dependency xhr2, albeit the original intent of this library is for the browser. For a more thorough solution for Node.js, see mikeal/request.

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()
    }
})

Promises

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

Options

  • url a fully qualified uri
  • method http method (default: GET)
  • headers http headers (default: {})
  • data entity body for PATCH, POST and PUT requests. Must be a query String or JSON object
  • type a string enum. html, xml, json, or jsonp. Default is inferred by resource extension. Eg: .json will set type to json. .xml to xml etc.
  • contentType sets the Content-Type of the request. Eg: application/json
  • crossOrigin for cross-origin requests for browsers that support this feature.
  • success A function called when the request successfully completes
  • error A function called when the request fails.
  • complete A function called whether the request is a success or failure. Always called when complete.
  • jsonpCallback Specify the callback function name for a JSONP request. This value will be used instead of the random (but recommended) name automatically generated by reqwest.

Security

If you are still requiring support for IE6/IE7, consider including JSON3 in your project. Or simply do the following

<script>
(function () {
  if (!window.JSON) {
    document.write('<scr' + 'ipt src="http://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"><\/scr' + 'ipt>')
  }
}());
</script>

Contributing

$ git clone git://github.com/ded/reqwest.git reqwest
$ cd !$
$ npm install

Please keep your local edits to src/reqwest.js. The base ./reqwest.js and ./reqwest.min.js will be built upon releases.

Running Tests

make test

Browser support

  • IE6+
  • Chrome 1+
  • Safari 3+
  • Firefox 1+
  • Opera

Ender Support

Reqwest can be used as an Ender module. Add it to your existing build as such:

$ ender add reqwest

Use it as such:

$.ajax({ ... })

Serialize things:

$(form).serialize() // returns query string -> x=y&...
$(form).serialize({type:'array'}) // returns array name/value pairs -> [ { name: x, value: y}, ... ]
$(form).serialize({type:'map'}) // returns an object representation -> { x: y, ... }
$(form).serializeArray()
$.toQueryString({
    foo: 'bar'
  , baz: 'thunk'
}) // returns query string -> foo=bar&baz=thunk

Or, get a bit fancy:

$('#myform input[name=myradios]').serialize({type:'map'})['myradios'] // get the selected value
$('input[type=text],#specialthing').serialize() // turn any arbitrary set of form elements into a query string

ajaxSetup

Use the request.ajaxSetup to predefine a data filter on all requests. See the example below that demonstrates JSON hijacking prevention:

$.ajaxSetup({
  dataFilter: function (response, type) {
    if (type == 'json') return response.substring('])}while(1);</x>'.length)
    else return response
  }
})

RequireJs and Jam

Reqwest can also be used with RequireJs and can be installed via jam

jam install reqwest
define(function(require){
  var reqwest = require('reqwest')
});

spm

Reqwest can also be installed via spm

spm install reqwest

jQuery and Zepto Compatibility

There are some differences between the Reqwest way and the jQuery/Zepto way.

method

jQuery/Zepto use type to specify the request method while Reqwest uses method and reserves type for the response data type.

dataType

When using jQuery/Zepto you use the dataType option to specify the type of data to expect from the server, Reqwest uses type. jQuery also can also take a space-separated list of data types to specify the request, response and response-conversion types but Reqwest uses the type parameter to infer the response type and leaves conversion up to you.

JSONP

Reqwest also takes optional jsonpCallback and jsonpCallbackName options to specify the callback query-string key and the callback function name respectively while jQuery uses jsonp and jsonpCallback for these same options.

But fear not! If you must work the jQuery/Zepto way then Reqwest has a wrapper that will remap these options for you:

reqwest.compat({
    url: 'path/to/data.jsonp?foo=bar'
  , dataType: 'jsonp'
  , jsonp: 'foo'
  , jsonpCallback: 'bar'
  , success: function (resp) {
      qwery('#content').html(resp.content)
    }
})

// or from Ender:

$.ajax.compat({
  ...
})

If you want to install jQuery/Zepto compatibility mode as the default then simply place this snippet at the top of your code:

$.ajax.compat && $.ender({ ajax: $.ajax.compat });

Happy Ajaxing!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].