PolymerElements铁ajax不发布数据 [英] PolymerElements iron-ajax not posting data

查看:63
本文介绍了PolymerElements铁ajax不发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在dom模块中的铁ajax元素: 这是我的javascript:

This here is my iron-ajax element inside a dom-module: This here is my javascript:

var iron_ajax = document.querySelector('iron-ajax');
iron_ajax.body = {"full_names":profile.getName(),"access_token":googleUser.getAuthResponse().id_token};
iron_ajax.generateRequest();

当我抓住$ _POST变量并将内容转储到文件中(将它们编码为json后),我得到[] (这意味着没有数据,零,什么都没有).当我在发送变量以确保不发送空格之前对它们进行.log()时,这些值的确会出现,因此不是在发送空格. 我认为这是一个错误,或者我只是不了解它是如何工作的.有人可以帮忙吗?谢谢.

When I grab the $_POST variable and dump the contents to a file (after encoding them as json) I get [] (That means no data, zero, nothing). When I .log() the variables before sending them to ensure I'm not sending blanks, the values do appear, so it's not that I'm sending blanks. I think it's a bug, or I just don't understand how it works. Can someone please help. Thanks.

推荐答案

我找到了解决方案.这不是聚合物问题.当您使用内容类型JSON进行POST时,不会填充$ _POST.在服务器端尝试此操作:

I found a solution. This is not a Polymer problem. When you POST with content type JSON $_POST will not populate. Try this at server side:

    $json = file_get_contents("php://input");
    $_POST = json_decode($json, true);

现在,您的POST-Array将充满您的请求数据.

Now your POST-Array will be filled with your request data.

这篇关于PolymerElements铁ajax不发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆