I am new to VUE.JS and searching and googling from sometime but i didn't find a satisfied solution.. Problem is as we submitting form through JQuery or Javascript so we can pass whole fields of the form with " new FormData(this) " this to our server side request. But problem is that its not working in VUE JS so Please I need a guidance that how can get all the data of form without creating a single variable of every field of the form...
<form id="testing">
<input type="text" name="email">
<input type="password" name="password">
<input type="submit" value="Save">
</form>
$(document).on('submit','#testing',function () {
event.preventDefault();
$.ajax({
url: url + "add-steps-process",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
dataType: 'json',
success: function (data)
{
}
})
})
VUE JS CODE
<form @submit.prevent="add_new_user()" id="new_user_form" method="post">
<input type="email" name="email" v-model="email">
<input type="password" name="password" v-model="password">
<button type="submit" class="btn btn-default">Add User</button>
</form>
IN MY DATA METHOD OF VUE JS
add_new_user:function(){
var ins = this;
var username = ins.email;
var passsword = ins.password;
var url = 'http://myURL/page';
$.ajax({
url: url+"add-user",
type: "POST",
data: {username,password},
success: function(data)
{
}
})
}
Now i want to avoid creating variable for every field i want the form should submit all the variables as without creating a single field variable.