Answer the question
In order to leave comments, you need to log in
How to work with server response in vuejs?
Something like this I send a post-request with Ajax, here I get the server response. How can I now place the response in another region of the page in the form of {{response}} ?
new Vue({
el: "#my_submit",
methods: {
send: function(){
axios.post('/my_page', json)
.then(function (response) {
console.log(response.data.foo);
})
.catch(function (error) {
console.log(error);
});
...
Answer the question
In order to leave comments, you need to log in
new Vue({
el: "#my_submit",
methods: {
send: function(){
axios.post('/my_page', json)
.then(function (response) {
this.somevar = response //<----------------------------------
console.log(response.data.foo);
})
.catch(function (error) {
console.log(error);
});
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question