亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

vue.js - vue-resource is not sending data to the php backend properly?
ringa_lee
ringa_lee 2017-06-15 09:22:37
0
3
790
// js 代碼
new Vue({
    el: "#app",
    data: {},
    methods: {
        get: function() {
            this.$http.get("get.php", {
                "a": 1,
                "b": 2
            }).then(function(res) {
                alert(res.data);
            }, function(res) {
                alert(res.status);
            })
        }
    }
})

----------

// php代碼 (本人對PHP一無所知)
// 變量之前加上@是因?yàn)椴患拥脑挄?huì)報(bào)一個(gè) undefined index :a的錯(cuò)
<?php
$a = @$_GET['a'];
$b = @$_GET['b'];

echo $a + $b
?>

After triggering the send event get, 0 is returned. In the example, 3 is returned. I have checked the code many times and it is exactly the same. Please solve it! Thanks!

ringa_lee
ringa_lee

ringa_lee

reply all(3)
三叔

get request to pass parameters like this:

this.$http.get("get.php", { 
  params: {
    "a": 1,
    "b": 2
  }
}).

Reference https://github.com/pagekit/vu...

黃舟

This library is no longer officially recommended, use the axios one

學(xué)習(xí)ing

The parameters of get should be added to the url, for example: get.php?a=1&b=2
This is the form of the parameters attached to the post method

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template