如何使用 Prototype(JS) 评估这个特定的 JSON?
来自服务器的数据变成了 JSON 数组,作为 requestText 和 ajax 请求:
Price : [{"id":"1","max_price":"100000"},{"id":"2","max_price":"150000"},{"id":"3","max_price":"200000.55"}]
Name : [{"id":"1","name":"P1"},{"id":"2","name":"P2"},{"id":"3","name":"P3"}]
我看到了这个方法的原型: var json = Transport.responseText.evalJSON(true);
我怎样才能获取 Price 数组,所以JSON 等于:
[{"id":"1","max_price":"100000"},{"id":"2","max_price":"150000"},{"id":"3","max_price":"200000.55"}]`
Data from a Server became a JSON array as responseText an ajax request :
Price : [{"id":"1","max_price":"100000"},{"id":"2","max_price":"150000"},{"id":"3","max_price":"200000.55"}]
Name : [{"id":"1","name":"P1"},{"id":"2","name":"P2"},{"id":"3","name":"P3"}]
I see into Prototype this method : var json = transport.responseText.evalJSON(true);
How can I just get the Price array, so JSON equals:
[{"id":"1","max_price":"100000"},{"id":"2","max_price":"150000"},{"id":"3","max_price":"200000.55"}]`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
php 需要包含 json 标头:
ajax 请求需要包含 evalScripts (确保您信任源):
然后您的函数可以像下面这样获取 json:
编辑: 还有直接来自源的这些说明:
http://www.prototypejs.org/learn/json
Edit2:以下是更新服务器的方法:
执行此操作后,在 js 中您可以执行类似以下操作(来自上面的 your_function 示例):
The php needs to include the json header:
The ajax request needs to include evalScripts (make sure you trust the source):
Then your function can get the json like the following:
Edit: There's also these instructions directly from the source:
http://www.prototypejs.org/learn/json
Edit2: Here's how to update the server:
after you do this, in js you can do something like the following (from the above your_function example):