KRL 中的处理客户端数组提升至 Kynetx 应用程序
概述
我正在构建一个 Kynetx 规则集,它将查找页面上的一堆 Facebook id,然后使用 Kynetx Facebook 模块获取与该 Facebook id 关联的 Facebook 头像。我有在页面上创建 Facebook id 数组的 JS,我可以在 KRL 中处理数组以检索 Facebook 头像。我不知道如何在 KRL 中将数组从客户端获取到服务器端。
如何从 KRL 客户端获取数组到服务器端?
Overview
I am working on building a Kynetx ruleset that will find a bunch of Facebook ids that are on the page and then use the Kynetx Facebook module to get the Facebook avatar associated with that Facebook id. I have the JS that creates an array of Facebook ids on the page and I can process an array in KRL to retrieve Facebook avatars. What I don't have is how to get an array from the client side to the server side in KRL.
How can I get the array from the client side to the server side of KRL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以获取 JavaScript 数组并将其转换为字符串,如果您解码它,它就会工作在 KRL 的服务器端。
示例应用程序代码=> https://gist.github.com/722536
示例应用书签 => http://mikegrace. s3.amazonaws.com/forums/stack-overflow/send-array-to-kns-dev-bookmarklet.html
从 http://example.com/
You can take a JavaScript array and convert it into a string and it will work if you decode it on the server side of KRL.
Example app code => https://gist.github.com/722536
Example app bookmarklet => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/send-array-to-kns-dev-bookmarklet.html
Results of running app from bookmarklet on http://example.com/
回答
不幸的是,KRL JS 运行时尚不支持将数组发送到服务器端。有一种方法可以完成您想做的事情。
示例
我构建了一个示例应用程序,该应用程序在此页面上运行,并带有一个书签,该书签获取问题所标记的标签,并将它们发送到服务器进行处理,然后返回。
示例应用代码 => https://gist.github.com/707561
示例应用书签 = > http://mikegrace. s3.amazonaws.com/forums/stack-overflow/client-side-array-to-server-bookmarklet.html
代码示例的逐步说明
结果从书签运行应用程序的结果:
Answer
Unfortunately, the KRL JS runtime doesn't yet support sending arrays to the server side. There is a way to accomplish what you are wanting to do though.
Example
I built an example app that runs on this page with a bookmarklet that gets the tags that the question is tagged with and sends them to the server to be processed and then they come back.
Example app code => https://gist.github.com/707561
Example app bookmarklet => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/client-side-array-to-server-bookmarklet.html
Step by step explination of code example
Results of running app from bookmarklet:
如果您对哈希数组进行 JSON.stringify,则还可以执行哈希数组。
示例应用:
在 example.com 上运行的结果
You can also do arrays of hashes if you JSON.stringify the array of hashes.
Example app:
Results of running on example.com