问题标签 [iron-ajax]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
251 浏览

php - Polymer、iron-ajax 和 PHP 后端 - 如何接收数组?

我有一个简单的 Iron-ajax 元素,如下所示:

然后稍后在 javascript 中,我向请求中添加了一些参数,其中一个是数组:

我有一个简单的 PHP 脚本,它接受所有这些参数,但不知道如何接收“cc”数组。

如果我尝试使用 GET 方法,iron-ajax 会生成如下查询字符串:

代替

因此,PHP 中的 $_GET["cc"] 只获取数组的最后一个值,“test3@test.com”。

当我尝试使用 POST 方法时,$_POST 始终为空...

任何人都知道如何使用 Iron-ajax 传递数组?

0 投票
1 回答
400 浏览

javascript - 聚合物铁阿贾克斯不工作

我正在测试 Polymer 的 Iron-ajax 调用。为此,我设置了一个虚拟视图:

然而,这不起作用。我想每半秒 ping 一次 API,但它甚至没有加载一次:我只是得到一个空圆圈。在此处输入图像描述

我在这里想念什么?为什么 API 调用不起作用?谢谢!

0 投票
0 回答
284 浏览

javascript - iron-ajax nested dom-repeat

I'm trying to make an initial iron Ajax call to URL that's returning a JSON array object to {{ajaxResponse}}. Nested within that array is a link property (ajaxResponse.item.link). I'm then trying to use that link, inside a dom-repeat over the array from the first request, to populate the URL for a second Iron Ajax request, which returns a preview of the link as a json object. Finally, I have a second dom-repeat that loops through each link in the initial array and displays the "title, desc, image" values from the second request in a paper-card.

Finally, I'm trying to use the platform and avoid using jquery or really anything other than polymer 2.0, web components, and vanilla javascript (aside from the 3rd party proxies/parsers I'm using). Also doing this all client side thus far. Have been able to get it working using a jquery library but had issues getting it styled using the method that was working and again I'm trying to do this without jquery.

This is my first post on here so let me know if I've omitted anything relevant or should have done a more thorough search before asking.

Changed unfurl to http per comment below. What would really help is if someone could answer the following: how do I access {{item.guid}} outside of the dom-repeat so I can do things like use a function to truncate the first four characters of the value and return the truncated value to the variable. (See comments below. Just realized I could edit this post instead of commenting on my own. Have read stackoverflow for years and learned a lot but this is my first time writing an app from (mostly) scratch and posting on the forum. Appreciate your patience with me!

I reposted this with all the code (cleaned up) and screenshot of results. Tested the APIs I'm using and they are working reliably. Here's link to the new post. Would greatly appreciate some feedback! Nested Iron Ajax

0 投票
0 回答
172 浏览

polymer - Polymer 2 iron-ajax 正在加载错误的本地文件

当使用 iron-ajax Polymer Web 组件加载本地 json 文件时,返回的响应是 index.html 的内容,而不是 json 文件。

我正在“网络”下的 Chrome 开发人员工具中检查响应,给出的响应与 index.html 文件相同。我使用 Polymer 2.0 入门套件作为前端,后端使用 Flask。抱歉,如果这是一个简单的错误,但我是 JavaScript 新手。

我的简化文件结构如下所示:

编辑:我相信问题可能与我正在使用的样板中的 app.py 文件中的这个包罗万象有关。我意识到我不明白相对 url 在这个应用程序中是如何工作的。

0 投票
1 回答
308 浏览

javascript - Iron ajax:如何从成功响应中解析 json 对象数组?

我正在对服务器进行铁 ajax 调用我将响应作为数组对象的数组作为 json

在我调用成功方法并打印我在控制台中获取的数据时的成功响应中,我应该如何在成功方法中解析这个对象数组的对象?

0 投票
1 回答
612 浏览

json - Iron-ajax 不支持 POST 请求的 content-type='application/json'

我正在尝试使用 iron-ajax,但 content-type='application/json' 不支持。

财产 -

计算函数 -

这不起作用,404 Bad request。我需要向我的服务器发送一个 JSON 对象。

错误信息-

0 投票
1 回答
74 浏览

xml - Polymer 2 Iron-ajax 与 handleAs=xml 错误?

我有以下代码:

在 Chrome 调试器中查看此请求将正确发送,答案 (xml) 也是正确的。让我发疯的是除了 handleAs="xml" 之外的所有内容都将正确设置。

但是在发送请求时,在 chrome 调试器 (iron-ajax.html:484) 中 - handleAs 始终(该死)设置为“json”。

在我看来,聚合物不会(!)正确设置 handleAs 属性!

还是我错过了什么?

0 投票
1 回答
1093 浏览

polymer - iron-ajax 找不到 generateRequest()-方法

我是 Polymer 的新手,并尝试通过 Iron-ajax 创建一个 ajax 调用。我遇到了一个错误,这generateRequest()是未定义的。

聚合物 1 正在使用中。

我用这个命令安装了 iron-ajax: bower install --save PolymerLabs/promise-polyfill#1

正如你所看到的,我加载它<link rel="import" href="../bower_components/promise-polyfill/promise-polyfill-lite.html">

我将其与一些示例进行比较,但找不到错误。有人有想法或解决方案吗?

这是代码:

0 投票
0 回答
264 浏览

polymer - Vaadin-upload:415 使用 vaadin 上传上传 csv 文件时不支持的媒体类型

我正在使用 Vaadin 上传 Web 组件https://vaadin.com/elements/vaadin-upload在使用 vaadin 上传上传 csv 文件后从前端上传 CSV 文件我收到 500 内部服务器错误 vaadin 上传组件是

我检查了标题多部分/表单数据被附加到标题中,我已经检查了邮递员的服务器端代码,我能够通过邮递员将 csv 文件发送到服务器端,但 UI 中没有发生同样的情况。 请求头 谁能帮助我我无法弄清楚?

服务器端代码是:

0 投票
2 回答
155 浏览

javascript - 来自路由参数的 Polymer Ajax 绑定不起作用

我正在使用 iron-pages 和 app-router 将我发送到一个新页面,我需要一个 iron-ajax 元素来发送带有从路由器发送的参数的请求。

但是,当我尝试在 Iron ajax 中添加我的参数 {{parameter.identifier}} 时,它不起作用。

我怀疑这与本地路由参数有关,而 Iron-ajax 看不到它?我试图为参数添加一个属性和一个 getter 函数,但似乎没有任何工作......

此外,我知道 ajax 是正确的,因为如果我将绑定变量 {{parameter.identifier}} 更改为数据库中存在的值,它就可以查询。