Rest 余烬在其他休息结束后发送休息
我有发送带有附件的信息的操作。若信息包含文件,则通过uploadInformationImage rest函数将其发送到服务器,该函数在数据库中重新获取其id。 主要功能是发送rest数据以将信息存储到数据库 但信息是在上传文件之前保存的。上传文件后如何保存信息Rest 余烬在其他休息结束后发送休息,rest,ember.js,Rest,Ember.js,我有发送带有附件的信息的操作。若信息包含文件,则通过uploadInformationImage rest函数将其发送到服务器,该函数在数据库中重新获取其id。 主要功能是发送rest数据以将信息存储到数据库 但信息是在上传文件之前保存的。上传文件后如何保存信息 actions: { addInformation: function() { var that = this; var title = $('#title1').val();
actions: {
addInformation: function() {
var that = this;
var title = $('#title1').val();
var information = '';
var blocksInOrder = $("#body_container").sortable("toArray");
blocksInOrder.forEach(function(item) {
Ember.RSVP.all([
that.uploadInformationImage(item).then(function(response) {
return response['document']['id'];
})
]).then(function(docId) {
information += '<p class="' + blocktype + '"><a href="' + docUrl + '" target="_blank">Download file</a></p>';
});
});
var dataObject = {
'title': title,
'information': information
};
Ember.$.ajax({
url: ENV.apiHost + "/api/informations/add_new",
type: 'POST',
contentType: "application/json",
data: JSON.stringify(dataObject)
});
}
}
代码底部的无条件Ember.$.ajax调用有什么用?跟踪foreach循环中的所有承诺,然后在其外部使用RSVP.all,并在其内部调用ajax调用。将其发送的rest信息记录拖到我的symfony2控制器