本文整理汇总了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);
}
});
};