本文整理匯總了TypeScript中tinymce/core/api/util/XHR.send函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript send函數的具體用法?TypeScript send怎麽用?TypeScript send使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了send函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
suite.asyncTest('Unsuccessful request', function (_, done) {
XHR.send({
url: '/custom/404',
error (type, xhr, input) {
LegacyUnit.equal(type, 'GENERAL');
LegacyUnit.equal(xhr.status, 404);
LegacyUnit.equal(input.url, '/custom/404');
done();
}
});
});
示例2: callback
return Future.nu((callback) => {
// TODO - better handling of failure
if (typeof linkList === 'string') {
XHR.send({
url: linkList,
success: (text) => callback(parseJson(text)),
error: (_) => callback(Option.none())
});
} else if (typeof linkList === 'function') {
linkList((output) => callback(Option.some(output)));
} else {
callback(Option.from(linkList));
}
}).map((opt) => opt.bind(ListOptions.sanitizeWith(extractor)));
示例3: success
return new Promise<string>((resolve, reject) => {
if (t.value.url) {
XHR.send({
url: t.value.url,
success (html: string) {
resolve(html);
},
error: (e) => {
reject(e);
}
});
} else {
resolve(t.value.content);
}
});
示例4: function
const createImageList = function (editor, callback) {
const imageList = Settings.getImageList(editor);
if (typeof imageList === 'string') {
XHR.send({
url: imageList,
success (text) {
callback(JSON.parse(text));
}
});
} else if (typeof imageList === 'function') {
imageList(callback);
} else {
callback(imageList);
}
};
示例5: function
const onSelectTemplate = function (e) {
const value = e.control.value();
if (value.url) {
XHR.send({
url: value.url,
success (html) {
templateHtml = html;
insertIframeHtml(editor, win, templateHtml);
}
});
} else {
templateHtml = value.content;
insertIframeHtml(editor, win, templateHtml);
}
win.find('#description')[0].text(e.control.value().description);
};
示例6: function
const createLinkList = function (editor, callback) {
const linkList = Settings.getLinkList(editor.settings);
if (typeof linkList === 'string') {
XHR.send({
url: linkList,
success (text) {
callback(editor, JSON.parse(text));
}
});
} else if (typeof linkList === 'function') {
linkList(function (list) {
callback(editor, list);
});
} else {
callback(editor, linkList);
}
};
示例7: function
return function () {
const templateList = Settings.getTemplates(editorSettings);
if (typeof templateList === 'function') {
templateList(callback);
return;
}
if (typeof templateList === 'string') {
XHR.send({
url: templateList,
success (text) {
callback(JSON.parse(text));
}
});
} else {
callback(templateList);
}
};
示例8: function
return function (method, text, doneCallback, errorCallback) {
const data = { method, lang: currentLanguageState.get() };
let postData = '';
data[method === 'addToDictionary' ? 'word' : 'text'] = text;
Tools.each(data, function (value, key) {
if (postData) {
postData += '&';
}
postData += key + '=' + encodeURIComponent(value);
});
XHR.send({
url: new URI(pluginUrl).toAbsolute(Settings.getRpcUrl(editor)),
type: 'post',
content_type: 'application/x-www-form-urlencoded',
data: postData,
success (result) {
result = JSON.parse(result);
if (!result) {
const message = editor.translate('Server response wasn\'t proper JSON.');
errorCallback(message);
} else if (result.error) {
errorCallback(result.error);
} else {
doneCallback(result);
}
},
error () {
const message = editor.translate('The spelling service was not found: (') +
Settings.getRpcUrl(editor) +
editor.translate(')');
errorCallback(message);
}
});
};