Parse data from an external JSON source to display

2019-03-04 11:08发布

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!

1条回答
乱世女痞
2楼-- · 2019-03-04 11:32

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.

查看更多
登录 后发表回答