mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 11:29:30 +08:00
Updated to 4.0.1
Added type information for timeout capability added to Fetch API.
This commit is contained in:
@@ -341,6 +341,31 @@ function(data: any) {
|
||||
error.reject();
|
||||
});
|
||||
|
||||
// Timeout:
|
||||
var formData2 = $.serialize($('form')[0]);
|
||||
fetch('../controllers/php-post.php', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
body: formData,
|
||||
// Set timeout:
|
||||
timeout: 10000
|
||||
})
|
||||
.then($.json)
|
||||
.then(function <postData>(data: any): any {
|
||||
if (data.email_check == "valid") {
|
||||
$("#message_ajax").html("<div class='successMessage'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>");
|
||||
$("#message_ajax").append('<p>' + data.msg + '</p>');
|
||||
} else {
|
||||
$("#message_ajax").html("<div class='errorMessage'>Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.</div>");
|
||||
}
|
||||
})
|
||||
// Catch timeout:
|
||||
.catch(function(error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
// $.jsonp:
|
||||
$.jsonp('https://api.github.com/users/rbiggs/repos?name=chipper', {timeout: 10000})
|
||||
.then($.json)
|
||||
|
||||
Vendored
+10
-9
@@ -1,4 +1,4 @@
|
||||
// Type definitions for chocolatechip v4.0.0
|
||||
// Type definitions for chocolatechip v4.0.1
|
||||
// Project: https://github.com/chocolatechipui/ChocolateChipJS
|
||||
// Definitions by: Robert Biggs <http://chocolatechip-ui.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -1280,7 +1280,7 @@ declare type OpenEndedDictionary = Object;
|
||||
* Interface for fetch API.
|
||||
*
|
||||
* @param input A string representing a valid url.
|
||||
* @param init An object literal of key value pairs to set method, headers, body, credentials or cache.
|
||||
* @param init An object literal of key value pairs to set method, headers, body, credentials, cache or timeout.
|
||||
* @return Promise.
|
||||
*/
|
||||
|
||||
@@ -1301,13 +1301,14 @@ interface fetch {
|
||||
include: string;
|
||||
};
|
||||
cache?: {
|
||||
default: string;
|
||||
"no-store": string;
|
||||
reload: string;
|
||||
"no-cache": string;
|
||||
"force-cache": string;
|
||||
"only-if-cached": string;
|
||||
}
|
||||
default: string;
|
||||
"no-store": string;
|
||||
reload: string;
|
||||
"no-cache": string;
|
||||
"force-cache": string;
|
||||
"only-if-cached": string;
|
||||
};
|
||||
timeout?: number;
|
||||
}): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user