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


TypeScript xhr.post函數代碼示例

本文整理匯總了TypeScript中xhr.post函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript post函數的具體用法?TypeScript post怎麽用?TypeScript post使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了post函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

        this.topicHandler.push(topic.subscribe('validateCode/validate', function(callback) {
            let validate = captchaObj.getValidate();
            if (!validate) {
                topic.publish('tipService/warning', lang.validateWarning);
                return;
            }
            let option: any = {
                handleAs: 'json',
                data: {
                    geetest_challenge: validate.geetest_challenge,
                    geetest_validate: validate.geetest_validate,
                    geetest_seccode: validate.geetest_seccode
                }
            };
            xhr.post(`${Config.requestHost}/validateCapthca`, option)
            .then((data)=>{
                if(!data.state || data.state != stateCode.SUCCESS) {
                    topic.publish('tipService/warning', data.info);
                } else {
                    callback();
                }
            }, (error)=>{

            });
        }));
開發者ID:qinqin65,項目名稱:QuickFinance,代碼行數:25,代碼來源:validateCode.ts

示例2: login

    login(userName: string, password: string, isRemenmber: boolean) {
        if(this.isLoginRequst) {
            return;
        }

        let option: any = {
            handleAs: 'json',
            data: {
                userName,
                password,
                isRemenmber
            }
        };
        xhr.post(`${Config.requestHost}/login`, option)
        .then((data)=>{
            if(!data.state || data.state != stateCode.SUCCESS || !data.user) {
                topic.publish('login/error', data.info);
            } else {
                this.isLogin = true;
                this.userName = userName;
                topic.publish('user/login', this);
            }
        }, (error)=>{
            topic.publish('login/error', lang.xhrErr);
        })
        .then(()=>this.isLoginRequst = false);

        this.isLoginRequst = true;
    }
開發者ID:qinqin65,項目名稱:QuickFinance,代碼行數:29,代碼來源:user.ts

示例3: it

 it("should receive correct data", function() {
     let option: any = {
         handleAs: 'json', 
         data: {
         'userName': 'testUserName',
         'password': 'testPassword'
         }
     };
     return xhr.post(`${Config.requestHost}/login`, option)
     .then((data)=>{
         chai.assert.equal(data.state, stateCode.Error);
     }, (error)=>{
         throw error;
     });
 });
開發者ID:qinqin65,項目名稱:QuickFinance,代碼行數:15,代碼來源:loginTest.ts

示例4: it

 it("should failed if not pass validation when changing password", function() {
     let timeStamp = new Date().getTime();
     let option: any = {
         handleAs: 'json',
         data: {
             oldPassword: '123456',
             newPassword: '654321'
         }
     };
     return xhr.post(`${Config.requestHost}/changingPassword`, option)
     .then((data)=>{
         chai.assert.equal(data.state, stateCode.Error);
     }, (error)=>{
         throw error;
     });
 });
開發者ID:qinqin65,項目名稱:QuickFinance,代碼行數:16,代碼來源:setupTest.ts

示例5: register

 register(userName: string, email: string, password: string) {
     let option: any = {
         handleAs: 'json',
         data: {
             userName,
             email,
             password
         }
     };
     xhr.post(`${Config.requestHost}/register`, option)
     .then((data)=>{
         if(!data.state || data.state != stateCode.SUCCESS || !data.user) {
             topic.publish('login/error', data.info);
         } else {
             topic.publish('login/error', lang.xhrRegSuccess);
         }
     }, (error)=>{
         topic.publish('login/error', lang.xhrErr);
     });
 }
開發者ID:qinqin65,項目名稱:QuickFinance,代碼行數:20,代碼來源:user.ts


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