1

I'm working on a personal project to display data from a remote server, the HTML code contains the something like the following:

<script>
jQuery.getJSON("http://someurl.com/something.cgi?
AJZ=1&STOCK=S",
function(data) {
if (data.information[0]) {
var returnHTML = "<table style=\"border: 1px solid #E0E0E0;border-collapse: collapse;\"     

It works fine on the remote server that calls the script, but I'm trying to just copy the data fields (they are 4 or 5 lines of textual data). I've attempted to write a simple perl script with use LWP::UserAgent and HTTP::Request::Common to fetch it to a html page, but the script data obviously needs a browser to execute.

The text displays fine when I visit the page, but when I try to incorporate it, I see a 'NOT AUTHORIZED' Anyone have any tips on how to accomplish this?

4

1 回答 1

1

Sounds like its a CORS (Cross-Origin Resource Sharing, http://www.w3.org/TR/cors/) problem, your remote server needs to allow cross domain access. Most servers are set up not to accept XMLHttpRequests from domains outside of their own, its a security measure to stop cross-domain scripting.

Or you could call a script on your local machine, a proxy script, that retrieves the data remotely for you and returns it to your javascript call.

Fetching a web page in Perl using LWP::Simple - http://www.onperl.net/Fetching-a-Web-Page-Module-LWP-Simple

于 2013-09-18T14:06:35.727 回答