1.3.97 • Published 4 years ago

vuejs-ajax v1.3.97

Weekly downloads
37
License
MIT
Repository
github
Last release
4 years ago

vuejs-ajax

Travis Build Version Downloads

It is a XHR plugin that works in specific features for Vue.js 2.x and and above versions. It has many similar features with jQuery's ajax() and Angular's $http().

It allows you to write more tidy code by solving many of the most common features used by developers in the core. Here are a few examples:

Prevent Duplicate Requests

One of the most common problems is the problem of sending dublicate requests at the same time. Vue.js Ajax solve it easily. You can find more information here.

File Uploading

File uploading with Ajax (XMLHttpRequest) can sometimes require you to write extra code. But it's very simple to do it with Vue.js Ajax. You can find more information here.

History

History feature to create a faster browsing experience. This means less elements to load and therefore faster browsing. But it's very simple to do it with Vue.js Ajax. There is a detailed explanation to here.

CSRF

This setting provides protection against CSRF attacks. You can find more information here.

Component Shifter

There is also Component Shifter which solves a different task. With componentShifter() you can load (with Vue.ajax) and render your Vue template (html) in your application by dynamic & async Vue.component(). You can also add components and run them nested. You can find more information here.


Setup

npm install vuejs-ajax --save

Usage

// ES6
import ajax from "vuejs-ajax"
Vue.use(ajax)

// ES5
var ajax = require("vuejs-ajax")
Vue.use(ajax)

Getting Started

The general shorthand version is as follows:

Vue.ajax.get(string url[, object data] [,object configurations])
    .then(function success[, function error])

Arguments

PropertyRequiredTypeDescription
urlYesStringA string containing the URL to which the request is sent.
dataNoObjectA plain object that is sent to the server with the request.
configurationsNoObjectA set of key/value pairs that configure the Vue.ajax request.

All of the above methods are a shorthand method of the Vue.ajax():

Vue.ajax({
    url: "http://example.com",
    method: "get" // post, put, patch, delete, head, jsonp
}).then(function(response) {
    console.log("Success", response.data)
}, function(response) {
    console.log("Error", response.statusText)
})

You can find detailed information about the Methods here.

Configurations

ConfigurationTypeDefaultAvailable
assetsString Or Object--
asyncBooleantruetrue, false
cacheBooleanfalsetrue, false
completeFunction--
csrfBooleantruetrue, false
dataObject--
fileInputsElement Object-Input file upload objects
hardReloadOnErrorBooleanfalsetrue, false
historyBooleanfalsetrue, false
headersObject--
methodStringgetdelete, get, head, jsonp, patch, post, put
preventDuplicateBooleantruetrue, false
scrollTopBooleanfalsetrue, false
timeoutInteger60000Time in milliseconds
titleString--
urlString--
urlDataObject--
withCredentialsBooleanfalsetrue, false

License

MIT

Copyright (c) 2019 Fatih Koca

1.3.97

4 years ago

1.3.96

4 years ago

1.3.95

4 years ago

1.3.94

4 years ago

1.3.93

5 years ago

1.3.92

5 years ago

1.3.91

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.73

5 years ago

1.3.72

5 years ago

1.3.71

5 years ago

1.3.7

5 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago