當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript XHR.send函數代碼示例

本文整理匯總了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();
     }
   });
 });
開發者ID:abstask,項目名稱:tinymce,代碼行數:11,代碼來源:XhrTest.ts

示例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)));
開發者ID:tinymce,項目名稱:tinymce,代碼行數:14,代碼來源:LinkListOptions.ts

示例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);
   }
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:15,代碼來源:Dialog.ts

示例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);
  }
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:16,代碼來源:Utils.ts

示例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);
  };
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:18,代碼來源:Dialog.ts

示例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);
  }
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:18,代碼來源:Dialog.ts

示例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);
    }
  };
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:19,代碼來源:Templates.ts

示例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);
      }
    });
  };
開發者ID:abstask,項目名稱:tinymce,代碼行數:39,代碼來源:Actions.ts


注:本文中的tinymce/core/api/util/XHR.send函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。