M
M
msdosx862018-08-04 10:17:07
PHP
msdosx86, 2018-08-04 10:17:07

Why does PHP not see the request data sent via Vue.js, but everything is ok via jquery?

in short, the form looks something like this

<form v-on:submit.prevent="onSubmit" >
    <input name="name" 
            type="text" 
            required
            v-model.trim="name">
    <input name="email" 
            type="email" 
            required
            v-model.trim="email">
    <textarea name="comment" 
                required
                v-model.trim="comment">
    </textarea>
    <button type="submit">Записать</button>
</form>

when submitting the form, the onSubmit method is called, in which on the PHP side the $_POST variable is empty when I do exactly the same, via jQuery
this.$http.post('my_url', {name: this.name});
$.ajax({ url: 'my_url', method: 'post', data: {name: this.name});

then everything works

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Koteezy, 2018-08-04
@msdosx86

In short, this is most likely:
https://stackoverflow.com/questions/18866571/recei...

A
Andrey, 2018-08-04
@VladimirAndreev

So in the chrome console, look at what is being sent, it's easy for json in the request body to leave

I
Ildus Siraev, 2018-08-06
@siril

When making a GET request in vue-resource , the second parameter is sent [config], not the [body]request
. So try this.
Documentation https://github.com/pagekit/vue-resource/blob/devel...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question