Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
聚合物芯ajax-won';t post-JSON?_Json_Polymer - Fatal编程技术网

聚合物芯ajax-won';t post-JSON?

聚合物芯ajax-won';t post-JSON?,json,polymer,Json,Polymer,我正在使用核心ajax检索JSON数据。将组件转换为JSON返回服务器是另一回事。在所有情况下,无论传入的contentType或handleAs参数是什么,我作为输入传入的JSON对象似乎都被转换回服务器头中的key=value 守则: var ajax = document.querySelector('core-ajax'); ajax.method = 'POST'; ajax.handleAs = 'JSON'; ajax.contentType = 'application/jso

我正在使用核心ajax检索JSON数据。将组件转换为JSON返回服务器是另一回事。在所有情况下,无论传入的contentType或handleAs参数是什么,我作为输入传入的JSON对象似乎都被转换回服务器头中的key=value

守则:

var ajax = document.querySelector('core-ajax');

ajax.method = 'POST';
ajax.handleAs = 'JSON';
ajax.contentType = 'application/json';
ajax.params = JSON.stringify(data);

ajax.go();
非常简单。Go中的日志将为我提供:

2014/07/22 14:23:09 utils.go:139: OPTIONS /1/users/173?access_token=(token)
2014/07/22 14:23:09 utils.go:124: POST /1/users/173?access_token=(token)
2014/07/22 14:23:09 users.go:379: full_name=Greg%20Johnson
我们已经证实我们这边没有发生任何变化。请求头运行得很好


我可能完全错过了什么。我们还可以如何成功发布JSON数据?

。params
用于URL参数。您想要的是将JSON发布为请求主体?为此,我相信您需要设置
.body
属性:

这应该可以做到:

ajax.body = data

请参见

。所以,在我的100页聚合物文档中的某个地方,这个答案可能只是在瞪着我。感谢你的牵手。