Polymer 1.0 的 iron-ajax 不向脚本传递任何内容

Polymer 1.0's iron-ajax passes nothing to script

我正在尝试使用 iron-ajax 元素将变量提交给 PHP 脚本,然后该脚本可以使用该变量并发回响应。我知道它会触发,因为脚本确实发回了响应,我可以将变量传回我的应用程序。但是,iron-ajax 绝对不会从应用程序向脚本发送任何内容。

我尝试了很多来自SO和官方文档的不同方法,但到目前为止没有任何结果。 Polymer 文档仍在进行中 - 我已经 运行 没有想法了。希望外面有人已经经历过同样的事情并且知道我做错了什么。

这是我目前得到的:

index.php

...
<template is="dom-bind" id="app">
...
<div id="output"></div>

<iron-ajax 
    id="ajax" 
    url="remove.php"
    method="GET" 
    handle-as="json" 
    content-type="application/json" 
    on-response="_onResponseRetrieved">
</iron-ajax>
<div id="12345">
<!-- when this button is tapped, the ajax fires -->
<paper-button id="Remove" on-tap="_remove">Remove</paper-button>
</div>
...
</template>
<script src="scripts/app.js"></script>
...

app.js

(function(document) {
'use strict';
...
app._remove = function(e) {
  var removeID = e.srcElement.parentElement.id;
  this.$.ajax.params = '{"ID":"'+removeID+'"}';
  this.$.ajax.generateRequest();
  };

app._onResponseRetrieved = function(e) {
  console.log(e);
  this.$.output = e.detail.response['output'];
  }
...
})(document);

remove.php

<?php
header('Content-Type: application/json');
// I read on github that this was at one point a 
// workaround for an iron-ajax POST bug, so I'm 
// checking it here just to make sure there's nothing
// getting missed, but it turns up empty anyways, 
// just like POST and GET
$json = file_get_contents("php://input");
$jsonData = json_decode($json, true);

// this just counts the # of variables this script 
// received
$output['output'] = "POST:(".count($_POST).")<br>";
$output['output'] .= "GET:(".count($_GET).")<br>";
$output['output'] .= "JSON:(".count($jsonData).")";
echo json_encode($output);
?>

输出

POST:(0)
GET:(0)
JSON:(0)

非常感谢。

param 属性 需要一个对象而不是字符串。以这种方式创建它

this.$.ajax.params = {"ID": removeID};