When testing my HTML code, I run it locally rather than on the same server as the website.
This could be the issue. The getJSON
function is an "ajax" call, and those are restricted by the Same Origin Policy. Your local file system does not have the same origin as
http://game4u.comuf.com/songs.json
(although some browsers may consider the local file system to match any origin; most do not).
If you have control over the content at
http://game4u.comuf.com/songs.json
, you can consider using JSON-P instead of JSON. JSON-P bypasses the restrictions of the Same Origin Policy. Another option is Cross-Origin Resource Sharing, which requires action on the server end to grant access to the origin "null" and also requires a browser that supports it (most modern ones do, but IE9 may require workarounds such as using XDR instead of XHR object; jQuery doesn't handle this automatically, though there are plug-ins available).
Additionally, as Musa mentioned, your JSON data is invalid. It would become valid if you fix the backslashes in the URL (they should be forward slashes [/] instead of backslashes [\]) and remove the trailing comma at the end of the list, which is not allowed in JSON.