1
I have an instance of Vue in which I take values from a form to send by ajax, I would like to clean the data saved by the v-models at once after sending, this is possible?
new Vue({
el: '#app',
data: {
campo1: "",
},
methods:{
saveForm:function() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//document.getElementById("demo").innerHTML = this.responseText;
alert(this.responseText);
}
};
xhttp.open("POST", "helpers/get_campo.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(
"campo1="+this.campo1
);
this.campo1 = "";
}
}
Put your code that calls ajax sff. It’s inside the right component?
– Miguel
In real situation I have several field, I would like to clear them after calling the saveForm method().
– David Vinicius