add nanoajax

This commit is contained in:
Nathan Cahill
2016-02-28 15:57:14 -07:00
parent 99c4fb76b5
commit 3c59752dca
2 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
/// <reference path="./nanoajax.d.ts" />
import * as nanoajax from 'nanoajax';
nanoajax.ajax({
url: '/some-get-url'
}, function (code, responseText) {})
nanoajax.ajax({
url: '/some-post-url',
method: 'POST',
body: 'post=content&args=yaknow'
}, function (code, responseText, request) {})

20
nanoajax/nanoajax.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
// Type definitions for nanoajax v0.2.4
// Project: https://github.com/yanatan16/nanoajax
// Definitions by: Nathan Cahill <https://github.com/nathancahill/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'nanoajax' {
interface RequestParameters {
url: string;
headers?: { [key: string]: string; };
body?: string|FormData;
method?: string;
cors?: boolean;
}
interface Callback {
(statusCode: number, response: string, request: XMLHttpRequest): any
}
export function ajax(params: RequestParameters, callback: Callback): XMLHttpRequest
}