Why can’t I parse this JSON url with javascript and jQuery?

Question by Matt W.: Why can’t I parse this JSON url with javascript and jQuery?
I’m trying to parse this JSON url and every tutorial I find for javascript and jQuery works fine with its own url but when I prepare and use the script with this one, it fails.
The url is: https://mtgox.com/code/data/ticker.php
It is a remote site so I cannot do any changes to it, and I’ve written a script in php that works, but I need it in javascript.
Thanks in advance for any help!
Yeah, I’ve just went with php and it works, but saddly my server won’t allow me to parse from Mt. Gox, yet it works with TradeHill.
With Mt. Gox is runs an indefinite load and it never completes pulling the information, but it works flawlessly on TradeHill.
On a friend’s server, both works. Is there a way to get this thing to work with Mt. Gox, assuming that it’s an .htaccess or phpini problem…

Best answer:

Answer by Gitlez
Because of the security features in Javascript. It will not allow you to load data from another server.

Solution: use a php file to gather the information for you. Running the simple php script on your server will allow Javascript to load it.

PHP Script:
echo file_get_contents('http://mtgox.com/code/data/ticker.php');
?>

**Note** If you are testing this on your personal computer, you will need a personal server to parse the php script for you. There are lots of free ones available. Let me know, through the email link on my profile page, if you need help with this. There are also lots of portable ones (they do not install files all over your system).

Cheers,
Gitlez

What do you think? Answer below!

About Admin