[英]Two request at same route emberjs 2
This is my scenario. 这是我的情况。
First I tried a modal as component. 首先,我尝试使用模式作为组件。 After I see this is incorrect, then I moved to ember-data and do this on the route.
看到这是不正确的,然后我移至ember-data并在路线上执行此操作。 I create a ember-data for location list (which be a component) and other for register values.
我为位置列表(属于组件)创建了余烬数据,为寄存器值创建了余烬数据。 I create the adapter and a serializer.
我创建了适配器和序列化器。 So I completely lost what do next.
所以我完全失去了下一步的工作。 How I do this, using a ember-data to search places(a GET) and a registration(POST) on the API?
如何使用余烬数据在API上搜索地点(GET)和注册(POST)?
if you have to make multiple requests at the same time you do 如果您必须同时提出多个要求,
Ember.RSVP.all([
$.ajax(...),
this.store.findAll('person'),
...
]).then(function([result1, result2, result3 ]){
console.log('all requests finished');
})
if you want sequential request (one after another) you simply chain them 如果要顺序请求(一个接一个),只需将它们链接
$.ajax(...).then((ajaxResult) => {
return this.store.findAll('person')
}).then((person)=>{
....
}).then(function(){
console.log('all requests finished')
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.