Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. Uncaught TypeError: login is not a function
  2. at Object.submit [as fn] (eval at Yr (vue.min.js:7), <anonymous>:2:369)
  3. at HTMLFormElement.<anonymous> (vue.min.js:6)
  4.  
  5. // register
  6. Vue.component("login-form",
  7. {
  8. template: // THE HTML FORM
  9. ,
  10. data: function () {
  11. return data;
  12. },
  13. ready: function () {
  14. this.isAuthenticated = this.checkIfAuthenticated();
  15. this.userName = localStorage.getItem("id_name");
  16. },
  17.  
  18. methods: {
  19. checkIfAuthenticated: function () {
  20. const users = [
  21. {
  22. id: 1,
  23. name: "tom"
  24. },
  25. {
  26. id: 2,
  27. name: "brian"
  28. },
  29. {
  30. id: 3,
  31. name: "sam"
  32. }
  33. ];
  34.  
  35. this.$set("users", users);
  36. },
  37. login: function () {
  38. const headers = { "Content-Type": "application/x-www-form-urlencoded" };
  39.  
  40. $.ajax({
  41. url: "/token",
  42. type: "post",
  43. data: `username=${this.login.username}&password=${this.login.password}`,
  44. headers: headers,
  45. success: function (data) {
  46. console.info(data);
  47. },
  48. error: function() {
  49. this.isValid = false;
  50. }
  51. });
  52. }
  53. }
  54. });
  55. // create a root instance
  56. var vue = new Vue({
  57. el: "#loginForm"
  58. });
  59.  
  60. <form action="" method="GET" v-on:submit.prevent="form_submit">
  61. <input type="text" name="text" id="text" v-model="text">
  62. <input type="submit" value="submit now">
  63. </form>
  64.  
  65. new Vue({
  66. el: 'body',
  67. data : {
  68. text : '',
  69.  
  70. },
  71. methods: {
  72. form_submit: function() {
  73. var live_add = "{{ route('testdata') }}";
  74. var access_token = "{{ csrf_token() }}";
  75. this.$http.post(live_add, { client_name: this.text, _token : access_token } ).then((response) => {
  76. console.log(response.data.client_name);
  77. }, (response) => {
  78. // some error callback
  79. });
  80. }
  81. }
  82. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement