开发者

problem receiving data from post in php

This is my called by post to mi php in the server

    $.ajax({
            async: false,
     开发者_Python百科       type: "POST",
            url: "services/ModelsService.php",
            data: "{IdModelo: "+$("#brand").val()+"}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(values){
                //do something
            }   
    });

Now when i'm going to uses the value send from the js. always failed appears blank. But the data it's sending good because when i debug the called with charles debugging proxy works well the request

problem receiving data from post in php

this is my php file

$json = json_decode($_POST,true);
echo $json[1]; //this bring me always blank

What i'm doing wrong in my code


echo $json['IdModelo'];

This is how you get it.

Passing the second argument true to json_decode will return an associative array so you should access array values using associative (string) index.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜