-
-
Save sineld/07a4edf7d8b4c40f750eba4173525eb9 to your computer and use it in GitHub Desktop.
Ajax validation with VueJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Vue({ | |
el: '#app', | |
data: { | |
formInputs: {}, | |
formErrors: {} | |
}, | |
methods: { | |
submitForm: function(e) { | |
var form = e.srcElement; | |
var action = form.action; | |
var csrfToken = form.querySelector('input[name="_token"]').value; | |
this.$http.post(action, this.formInputs, { | |
headers: { | |
'X-CSRF-TOKEN': csrfToken | |
} | |
}) | |
.then(function() { | |
form.submit(); | |
}) | |
.catch(function (data, status, request) { | |
this.formErrors = data.data; | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source URL: http://taha-sh.com/blog/setting-up-ajax-validation-with-laravel-vuejs-in-no-time