I will get error invalid format
when I submit my form with array but I really didn’t know what is the problem. I have tried to Json.parse the array but still fail.
How can I submit a form with array? Should I pass the array to a variable first then only submit the variable instead of direct submitting the array?
html:
<input type="text" align="middle" v-model="domains.one">
<input type="text" align="middle" v-model="domains.two">
<button type="button" @click="submit">submit</button>
Vuejs:
new Vue({
el: "#app",
data: {
domains: [{one:""},{two:""}],
},
methods: {
addCompanySetting() {
var postData = '&domain='+this.domains';
$.ajax({
url:baseUrl+'/agency/account/prefer-ma',
type: 'POST',
data: postData,
dataType: 'json'
}).done(function (data){
if(data.result == "1"){
console.log("success");
}else{
console.log("error");
}
});
}
}