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