• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript jQuery.ajax函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中jQuery.ajax函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ajax函数的具体用法?TypeScript ajax怎么用?TypeScript ajax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ajax函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: return

    return Rx.Observable.create( (observer:Rx.Observer<any>) => {

        let xhr = $.ajax({
                url: '/proxy/en.wikipedia.org/w/api.php',
                async:true,
                timeout: 1500,
                cache:false,
                data: {
                    action: 'opensearch',
                    format: 'json',
                    search: term
                },
                error: (jqXHR: JQueryXHR, textStatus: string, errorThrown: string) => {
                      //console.log( "error", textStatus, errorThrown);
                      observer.error( errorThrown );
                },
                success: (data: any, textStatus: string, jqXHR: JQueryXHR) => {
                    //console.log( "data", data);
                    observer.next( data );
                    observer.complete();
                }
          });
          return () => { // On Unsubscribe
            if( xhr!=null && !xhr.status) {
                xhr.abort();
                console.log( "canceled!" );    
            }

          }
    });
开发者ID:bsorrentino,项目名称:rxjs-samples,代码行数:30,代码来源:autocomplete.ts


示例2: function

var updateTable = function() {
    $.ajax({
        url: "/peekLeaderboard",
        dataType: 'json'
    })
    .done(function(data) {
        let usernames = data.Usernames
        console.log(usernames)
        let scores = data.Scores
        let table = "<table id='leaderboard-table'>\
                      <thead>\
                        <tr>\
                          <th></th>\
                          <th>Name</th>\
                          <th>Score</th>\
                        </tr>\
                      </thead>"
        table += "<tbody>"
        for (var i = 0; i < 10; i++) {
            table += "<tr>\
            <td>" + (i + 1).toString() + "</td>"
         + "<td>" + usernames[i] + "</td>"
         + "<td>" + scores[i] + "</td></tr>"
        }
        table +=  "</tbody>"
        document.getElementById("leaderboardTable").innerHTML = table
    })
}
开发者ID:michaelRadigan,项目名称:outgain,代码行数:28,代码来源:leaderboard.ts


示例3: fetchServerConfig

export function fetchServerConfig(){
    return $.ajax({
        url: getConfigurationServiceApiUrl(),
        dataType: "jsonp",
        jsonpCallback: "callback"
    });
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:7,代码来源:config.ts


示例4: getImages

export function getImages(keyword) {
  let options: JQueryAjaxSettings = {
      url: `${CLIP_ART_ENDPOINT}?query=${keyword}&amount=20`
  };

  return $.ajax(options);
}
开发者ID:TienSFU25,项目名称:graphical-memories,代码行数:7,代码来源:openClipartApi.ts


示例5: findFilesByName

 function findFilesByName(text, onComplete) {
    let originalText = text;
    
    if(text && text.length > 1) {
       $.ajax({
          url: '/file/' + Common.getProjectName() + '?expression=' + originalText,
          success: function (filesMatched) {
             var response = [];
             
             for(var i = 0; i < filesMatched.length; i++) {
                var fileMatch = filesMatched[i];
                var typeEntry = {
                   resource: fileMatch.resource,
                   path: fileMatch.path,
                   name: fileMatch.name,
                   project: Common.getProjectName()
                };
                response.push(fileMatch);
             }
             onComplete(response, originalText);
          },
          async: true
       });
    } else {
       onComplete([], originalText);
    }
 }
开发者ID:snapscript,项目名称:snap-develop,代码行数:27,代码来源:commands.ts


示例6: fetchStaleVersionInfo

 private static fetchStaleVersionInfo() {
   return $.ajax({
     method: "GET",
     url: Routes.apiv1StaleVersionInfoPath(),
     beforeSend: mrequest.xhrConfig.forVersion("v1")
   });
 }
开发者ID:Skarlso,项目名称:gocd,代码行数:7,代码来源:version_updater.ts


示例7: it

  it('should PUT', async () => {
    mock.use((req, res) => {
      expect(req.method()).to.eq('PUT');
      expect(String(req.url())).to.eq('/');
      expect(req.body()).to.eq(JSON.stringify({foo: 'bar'}));
      return res
        .status(200)
        .reason('OK')
        .header('Content-Length', '12')
        .body('Hello World!');
    });

    const res = await $.ajax({
      method: 'put',
      url: '/',
      data: JSON.stringify({foo: 'bar'})
    })
      .then((data, status, xhr) => {
        expect(xhr.status).to.eq(200);
        expect(xhr.statusText).to.eq('OK');
        expect(xhr.getAllResponseHeaders()).to.contain(
          'content-length: 12\r\n'
        );
        expect(data).to.eq('Hello World!');
      })
      .catch((xhr, status, error) => expect.fail(error));
  });
开发者ID:jameslnewell,项目名称:xhr-mock,代码行数:27,代码来源:jquery.test.ts


示例8: save

	/**
	 * @memberof RegistrationController
	 * @this RegistrationController
	 * @instance
	 * @method save
	 * @desc Registers or updates the current device
	 */
	private save(): void {
		// Get the device details
		this.device.name = String($("#deviceName").val());

		// Send a PUT request to the server, including the device ID in the request headers
		$.ajax({
			url: `/devices/${this.device.name}`,
			context: this,
			type: "PUT",
			headers: {
				"X-DEVICE-ID": String(this.device.id)
			},
			success(_registrationReponse: string, _status: JQuery.Ajax.SuccessTextStatus, jqXHR: JQuery.jqXHR): void {
				// Get the device ID returned in the Location header
				this.device.id = jqXHR.getResponseHeader("Location");

				const device: Setting = new Setting("Device", JSON.stringify(this.device));

				// Update the database
				device.save();

				// Pop the view off the stack
				this.appController.popView();
			},
			error: (request: JQuery.jqXHR, statusText: JQuery.Ajax.ErrorTextStatus): void => this.appController.showNotice({
				label: `Registration failed: ${statusText}, ${request.status} (${request.statusText})`,
				leftButton: {
					style: "cautionButton",
					label: "OK"
				}
			})
		});
	}
开发者ID:scottohara,项目名称:tvmanager,代码行数:40,代码来源:registration-controller.ts


示例9: showFileHistory

 export function showFileHistory() {
    var editorState: FileEditorState = FileEditor.currentEditorState();
    var editorPath: FilePath = editorState.getResource();
 
    if(!editorPath) {
       console.log("Editor path does not exist: ", editorState);
    }
    var resource = editorPath.getProjectPath();
    
    $.ajax({
       url: '/history/' + Common.getProjectName() + '/' + resource,
       success: function (currentRecords) {
          var historyRecords = [];
          var historyIndex = 1;
          
          for (var i = 0; i < currentRecords.length; i++) {
             var currentRecord = currentRecords[i];
             var recordResource: FilePath = FileTree.createResourcePath(currentRecord.path);
             
             historyRecords.push({ 
                recid: historyIndex++,
                resource: "<div class='historyPath'>" + recordResource.getFilePath() + "</div>", // /blah/file.snap 
                date: currentRecord.date,
                time: currentRecord.timeStamp,
                script: recordResource.getResourcePath() // /resource/<project>/blah/file.snap
             });
          }
          w2ui['history'].records = historyRecords;
          w2ui['history'].refresh();
       },
       async: true
    });
 }
开发者ID:snapscript,项目名称:snap-develop,代码行数:33,代码来源:history.ts


示例10: unregister

	/**
	 * @memberof RegistrationController
	 * @this RegistrationController
	 * @instance
	 * @method unregister
	 * @desc Unregisters the current device
	 */
	private unregister(): void {
		// Send a DELETE request to the server
		$.ajax({
			url: `/devices/${this.device.id}`,
			context: this,
			type: "DELETE",
			headers: {
				"X-DEVICE-ID": String(this.device.id)
			},
			success(): void {
				const device: Setting = new Setting("Device", null);

				// Remove the device from the database
				device.remove();

				// Pop the view off the stack
				this.appController.popView();
			},
			error: (request: JQuery.jqXHR, statusText: JQuery.Ajax.ErrorTextStatus): void => this.appController.showNotice({
				label: `Unregister failed: ${statusText}, ${request.status} (${request.statusText})`,
				leftButton: {
					style: "cautionButton",
					label: "OK"
				}
			})
		});
	}
开发者ID:scottohara,项目名称:tvmanager,代码行数:34,代码来源:registration-controller.ts



注:本文中的jQuery.ajax函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript jQuery.data函数代码示例发布时间:2022-05-25
下一篇:
TypeScript jQuery.Deferred函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap