After carefully reviewing the documentation, I implemented the code below. While I am successfully retrieving data for enquiryDesc
, I am encountering null values for rating. Despite trying various troubleshooting steps, the issue with null values persists.
My HTML form is as follows:
<form id="enquiryBox" method="POST" onSubmit="return false;" data-parsley-validate="true" v-on:submit="handelSubmit($event);">
<div class="modal-body brbottom-20">
<div class="clearfix">
<div class="col-lg-6">
<div class="form-group required">
<fieldset class="rating">
<input v-model="rating" type="radio" id="rating" name="rating" v-bind:value="5" ><label v-bind:value="5" class = "full" for="star5" title="Awesome"></label>
<input v-model="rating" type="radio" id="rating" name="rating" v-bind:value="4" ><label v-bind:value="4" class="half" for="star4half" title="Pretty good"></label>
</fieldset>
</div>
</div>
<div class="col-lg-6">
<div class="form-group required">
<label>Enquiry</label>
<textarea placeholder="Write your enquiry here" rows="7" id="enquiryDesc" name="enquiryDesc" class="form-control required" title="Desc" v-model="enquiryDesc" required="required"></textarea>
</div>
</div>
</div>
</div>
<div class="">
<button id="btn-submit-enquiry" class="btn whiteButton" type="submit">Post Enquiry</button>
</div>
</form>
The Vue.js script associated with the form is shown below:
enquiryBox = new Vue({
el: "#enquiryBox",
data: {
rating: '',
enquiryDesc: '',
},
methods: {
handelSubmit: function(e) {
var vm = this;
data = {};
data['rating'] = this.rating;
data['enquiryDesc'] = this.enquiryDesc;
console.log(data);
$.ajax({
url: 'https://api/post/add_review/',
data: data,
type: "POST",
dataType: 'json',
success: function(e) {
if (e.status) {
alert("Success")
} else {
vm.response = e;
alert(" Failed")
}
}
});
return false;
}
},
});
When I check the response from console.log(data)
, it shows:
{rating: '', enquiryDesc: "cghjl,./"}
Despite using v-model
and v-bind:value
, I still face issues with not getting the values. Could there be an initialization problem causing this? Any assistance or solution would be greatly appreciated, as I have exhausted all available resources without success.