var data = {name:this.name,phone:this.phone,num:this.xhr};
console.log(data)
this.$http.post('location.href, data,function (data, status, request) {
}).error(function (data, status, request) {
})
在php里 var_dump($_POST) == array(0) { } ?
应该是 array(3) { ["name"]=> string(2) "32" ["phone"]=> string(2) "23" ["num"]=> string(1) "0" }才对啊
Please try to use english, especially on this repository, since it's not maintained by Evan :smile:
Very strange,In PHP Can't get to POST data ,See code:
post data : {name:me,phone:10}
Output : var_dump($_POST) == array(0) { } ,
Normal should be: var_dump($_POST) == array(0) { ["name"]=> string(2) "me" ,["phone"]=>10} ,
Please forgive my English level is not good :
There must be something wrong on JS code, you didn't post it complete, there is even syntax error:
this.$http.post('location.href, data,function (data, status, request) {
No error, the request was successful.
Is the server side to get POST data failure,
you probably mean location.href, not 'location.href'.
Not sure what is wrong though.. have been using this with PHP also, without problems.
Double check your setup, they should be something wrong with it, not with vue-resource.
Excuse me, My carelessness,please don't tangle in location.href and 'location.href'.,
The problem is Server access to POST data,But Request Method is POST,So strange
@seekwe The post data is send JSON encoded, in order to decode it in PHP you need to do this:
$data = json_decode(file_get_contents('php://input'), true);
var_dump($data);
If you want to use the normal $_POST data you need to enable the emulateJSON option:
Vue.http.options.emulateJSON = true;
thanks! The original is the problem of request payload :)
what does it mean request payload.
Most helpful comment
@seekwe The post data is send JSON encoded, in order to decode it in PHP you need to do this:
If you want to use the normal $_POST data you need to enable the emulateJSON option: