weixin_33743661 2014-08-15 00:12 采纳率: 0%
浏览 33

angularjs json标头请求

if I do this I can get a data .. but, it's not json..

     var url = 'inputtest.php';
     $http({
         method: 'POST',
         url: url,
         data: $.param($scope.company),
         headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
        }).success(function(response){
            console.log(response);
        });

so, if I change like this

           headers: { 'Content-Type': 'application/json; charset=UTF-8'}

I don't get any parameter from it.

===> headers info says "Request Payload" ?? instead of Request Data

server side. just testing it.

          echo json_encode($_REQUEST); 

I don't know what's wrong and how to fix it.

Any advice ?

  • 写回答

2条回答 默认 最新

  • 程序go 2014-08-15 00:25
    关注

    i think it's not a javascript problem but more a server side issue.

    You should try to add header('Content-Type: application/json'); before your echo in your php file

    评论

报告相同问题?

悬赏问题

  • ¥15 Qt安装后运行不了,这是我电脑的问题吗
  • ¥15 数据量少可以用MK趋势分析吗
  • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
  • ¥15 大智慧怎么编写一个选股程序
  • ¥100 python 调用 cgps 命令获取 实时位置信息
  • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
  • ¥15 C语言使用vscode编码错误
  • ¥15 用KSV5转成本时,如何不生成那笔中间凭证
  • ¥20 ensp怎么配置让PC1和PC2通讯上
  • ¥50 有没有适合匹配类似图中的运动规律的图像处理算法