Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uncaught TypeError: login is not a function
- at Object.submit [as fn] (eval at Yr (vue.min.js:7), <anonymous>:2:369)
- at HTMLFormElement.<anonymous> (vue.min.js:6)
- // register
- Vue.component("login-form",
- {
- template: // THE HTML FORM
- ,
- data: function () {
- return data;
- },
- ready: function () {
- this.isAuthenticated = this.checkIfAuthenticated();
- this.userName = localStorage.getItem("id_name");
- },
- methods: {
- checkIfAuthenticated: function () {
- const users = [
- {
- id: 1,
- name: "tom"
- },
- {
- id: 2,
- name: "brian"
- },
- {
- id: 3,
- name: "sam"
- }
- ];
- this.$set("users", users);
- },
- login: function () {
- const headers = { "Content-Type": "application/x-www-form-urlencoded" };
- $.ajax({
- url: "/token",
- type: "post",
- data: `username=${this.login.username}&password=${this.login.password}`,
- headers: headers,
- success: function (data) {
- console.info(data);
- },
- error: function() {
- this.isValid = false;
- }
- });
- }
- }
- });
- // create a root instance
- var vue = new Vue({
- el: "#loginForm"
- });
- <form action="" method="GET" v-on:submit.prevent="form_submit">
- <input type="text" name="text" id="text" v-model="text">
- <input type="submit" value="submit now">
- </form>
- new Vue({
- el: 'body',
- data : {
- text : '',
- },
- methods: {
- form_submit: function() {
- var live_add = "{{ route('testdata') }}";
- var access_token = "{{ csrf_token() }}";
- this.$http.post(live_add, { client_name: this.text, _token : access_token } ).then((response) => {
- console.log(response.data.client_name);
- }, (response) => {
- // some error callback
- });
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement