I
I
Ingvar Von Bjork2018-02-26 22:39:25
Vue.js
Ingvar Von Bjork, 2018-02-26 22:39:25

How to send and receive data in vue-resource?

To send, I do this:

new Vue({
  el: '#id',
  data: {
    endpoint: 'send.php'
  },
  methods: {
    send: function() {
      var options = {
        params: {
          'get': 'test'
        }
      }

      this.$http.post(this.endpoint, options).then(function(responce) {
        alert(responce.data);
      }, function(error) {
        alert('error');
      })
    }
  }
})

And in the php file the following code:
echo ($_POST['get'] == null)? 'false': $_POST['get'];

When sending, an alert pops up with the text false, i.e. infa then came, but something emptiness came.
What could be wrong here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem0071, 2018-02-26
@DeboshiR

try it:
file_get_contents('php://input')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question