xsds

Tiny javascript library written to send in-browser http requests either GET, POST or using any other HTTP supported method. It can help in scenarios like auto-login & others. What it actually does (by default) is opens up a new tab (in most cases) for the provided URL with the data parameters as if it was submitted from a form. Written in coffeescript, but precompiled to Javascript for a non-coffee developer (but you better should get on-board with coffee). If you got any suggestions or you can help improve, kindly send me a pull request with your contribution & I promise a consideration.


Keywords
cors, ajax, cross, domain, http, post, form, submission
License
MIT
Install
Install-Package xsds -Version 1.0.3

Documentation

{CROSS} X-SITE DATA SUBMISSION

Tiny javascript library written to send in-browser http requests either GET, POST or using any other HTTP supported method. It can help in scenarios like auto-login & others.

What it actually does (by default) is opens up a new tab (in most cases) for the provided URL with the data parameters as if it was submitted from a form.

Written in coffeescript, but precompiled to Javascript for a non-coffee developer (but you better should get on-board with coffee). If you got any suggestions or you can help improve, kindly send me a pull request with your contribution & I promise a consideration.

Installation

Archive

The download, extract & move thing always works in conditions when asset management is not required or configured. Just download this repo as zip or tar archive & do it the traditional way.

Bower

If you are using bower, you can simply run below command to install & start using XSDS. It assumes you have node.js + bower already installed & setup in PATH:

bower install xsds

Nuget

For ASP.net users, similar thing goes with nuget:

Install-Package xsds

Examples

If you experience problems with receiving requests from a domain to the target domain, you may consider reading this article.

Basic

You can simply pass the url & object to be posted as form data when calling the xsds.get(url, data) or xsds.post(url, data) methods.

# Coffeescript
# xsds.get ..., {} =
xsds.post "http://www.example.com/grab.php", {} =
  email: "someone@example.com"
  password: "00112233"
// Javascript
// xsds.post(..., {
xsds.post("http://www.example.com/grab.php", {
  email: "someone@example.com",
  password: "00112233"
});

Advanced

To pass additional supported cofiguration options, use the xsds.send(options) method instead.

# Coffeescript
xsds.send {} =
  autoremove: true
    data: {} =
    email: "someone@example.com"
    password: "00112233"
  method: "POST" # GET
  newtab: true
  url: "http://www.example.com/grab.php"
// Javascript
xsds.send({
  autoremove: true,
  data: {
    email: "someone@example.com",
    password: "00112233"
  },
  method: "POST", // GET
  newtab: true,
  url: "http://www.example.com/grab.php"
});

AMD Module

XSDS registers itself as an AMD module, so you can also use it asynchorously with require.js or similar libraries.

# Coffeescript
require [ "xsds" ], (xsds) ->
  # ...the async way
// Javascript
require([ "xsds" ], function(xsds) {
  // ...the async way
});

jQuery

If you are using jQuery, then you can call XSDS methods as you would like with a jQuery plugin. The usable methods are $.xsdsg(url, data), $.xsdsp(url, data) & $.xsds(options)

# Coffeescript
# $.xsdsg ..., {} =
$.xsdsp "http://www.example.com/grab.php", {} =
  email: "someone@example.com"
  password: "00112233"
// Javascript
// $.xsdsg(..., {
$.xsdsp("http://www.example.com/grab.php", {
  email: "someone@example.com",
  password: "00112233"
});

This is on GitHub so just raise an issue if you find something to be considered as a bug.

Open-source Javascript library project by: Vaibhav Pandey a.k.a VPZ