【发布时间】:2018-08-06 00:35:49
【问题描述】:
我的html表单是
<form method="POST" enctype="multipart/form-data" v-on:submit.prevent="handelSubmit($event);">
<div class="clear">
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="form-group">
<label>Offer <small>(required)</small></label>
<input type="file" name="offer" accept="image/*" required="">
</div>
<div class="form-group">
<div class="form-group">
<label>Place :</label>
<select id="basics" class="selectpicker" data-live-search="true" data-live-search-style="begins" title="Select Place" name="places" ref="place" multiple="">
<option v-for="post in places" v-bind:value="post.id" >{{post.name}}</option>
</select>
</div>
<input type='submit' class='btn btn-finish btn-primary' name='finish' value='Finish' />
</div>
</div>
</form>
我的vue js代码是
handelSubmit: function(e) {
var form = e.target; // Get hold of the form element from the event
var fd = new FormData(form); // create a FormData
fd.append('auth-token',this.authType)
fd.append('post',this.postId)
console.log(...fd);
$.ajax({
url: 'http://127.0.0.1:8000/alpha/add/offer/',
data: fd,
type: 'POST',
processData: false, // Important!
contentType: false,
success: function(e) {
if (e.status)
{
$("#alertModal").modal('show');
$(".alert").removeClass("hidden").html("Your Offer has been successfully added");
}
else {
alert("Registration Failed")
}
}
});
return false;
},
我需要选择多个适合我的地方。我需要发送这些用逗号分隔的多个地方。怎么能发这些地方用逗号隔开,现在是一个一个发。我需要发送以逗号分隔的地点。请帮助我获得同样的信息。
否则还有其他方法吗?
【问题讨论】:
标签: javascript html vue.js vue-component form-data