解析来自外部JSON源的数据以显示在表格中 - 获取最新数据。 [英] Parse data from an external JSON source to display in table - Get latest data.

查看:136
本文介绍了解析来自外部JSON源的数据以显示在表格中 - 获取最新数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正尝试从 http://www.epgpweb。 com / guild / us / Caelestrasz / Crimson /



正如您所看到的,有一个下拉菜单显示两个不同的屏幕截图。我想让表格显示最新的数据截图。



我的代码目前是

http://jsfiddle.net/QQSGR/



我正在尝试从而获取来自 http://www.epgpweb。的最新JSON数据。 com / api / snapshot / us / Caelestrasz / Crimson



我现在仍然坚持不懈,对于任何可以解决此问题的人都不知道,我!



目前表的工作版本可以在这里找到 - http://testing.lifestyletrader.com/DOM/index2.php



请帮忙!

$ b $一般来说,javascript(ajax)不能对另一个域进行ajax调用。有两个例外JSONP必须由您所调用的域支持,或者某些浏览器将允许POST但仍不会返回任何外部数据。它是一个安全的事情。



如果您需要在域之外进行javascript / ajax调用,那么您必须使用您最喜欢的编程语言(Java / JSP ,PHP,.net,asp)。我已经在这里发布了一个Java代码示例的答案:



jQuery ajax GET返回405方法不允许



Javascript does not a尽管使用JSON很好,但我建议将PHP代码设置为简单传递(如我的示例中的Java代码),从JavaScript调用它,然后在Javascript中处理内容。例如,有一个名为datatables的JQuery插件可用于构建表。


I am currently try to grab the data from http://www.epgpweb.com/guild/us/Caelestrasz/Crimson/

As you can see there is a dropdown menu that shows two different screenshots. I want the table to display the most recent data screenshot.

My code currently is

http://jsfiddle.net/QQSGR/

I am trying to get it to grab the most recent JSON data from http://www.epgpweb.com/api/snapshot/us/Caelestrasz/Crimson

I am at a stand still and have no idea, major rep for anyone who can solve this for me!

Currently the working version of the table can be found here - http://testing.lifestyletrader.com/DOM/index2.php

Please help!

解决方案

In general javascript (ajax) cannot make an ajax call to another domain. There are two exceptions JSONP which has to be supported by the domain you're calling, or some browsers will allow a POST but still won't return any external data. Its a security thing.

If you need to make a javascript/ajax call outside of your domain then you have to create a proxy in your favorite programming language (Java/JSP, PHP, .net, asp). I've posted an answer with an example of Java code for this here:

jQuery ajax GET returns 405 Method Not Allowed

Javascript does do a great job with JSON though so I'd suggest setting up your PHP code as a simple pass-through (like the java code in my example), call it from javascript, and deal with the content in Javascript. For instance there is a JQuery pluging called datatables you could use to build the table.

这篇关于解析来自外部JSON源的数据以显示在表格中 - 获取最新数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆