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 电脑键盘实现触摸功能
  • ¥25 matlab无法将表达式转换为双数组怎么解决?
  • ¥15 单片机汇编语言相关程序
  • ¥20 家用射频美容仪技术规格
  • ¥15 大家帮我看看为什么错了
  • ¥15 unity互动琴弦抖动效果
  • ¥15 做了个的二极管反向饱和电流测量电路,但是测试达不到效果
  • ¥15 nginx无证书访问https失败
  • ¥15 树莓派启动AP热点传入数据
  • ¥15 multisim中关于74ls192n和DSWPK开关的问题(相关搜索:计数器)