Vuejs AJAX From Submit using Laravel PHP

Vuejs AJAX From Submit using Laravel PHP

In this Post We Will Explain About is Vuejs AJAX From Submit using Laravel PHP With Example and Demo.

Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Submit form using VueJs and AJAX in Laravel Example

In this post we will show you Best way to implement Laravel 5.4 login with ajax using vuejs and laravel, hear for How to Handling Laravel Validation Error Messages With Vue.js with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  AngularJS Nested ng-repeat Get Multiple checkbox value

If we are some looking for a basic vuejs structure of PHP laravel, as well as VueJS and simple AJAX post data method, and then here some code is the simple solutions for you.

In view using Vuejs

<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>

In your controller method using Vuejs

public function testdata(Request $request)
{
    return [
        'client_name' => $request->input('text')
    ];
}

In your VueJS file using Vue

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
        });
    }
  }
});

Example

READ :  C# Code Optimizing Tutorial with Examples

I hope you have Got Handling Laravel Validation Error Messages With Vue.js And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

Add a Comment

Your email address will not be published. Required fields are marked *