Skip to content Skip to sidebar Skip to footer

Get Data Out Of Json Array From External Url

I am relatively new to JSON. I have read the tutorial and trying to implement it but no luck. Basically I have an external URL that gives JSON data/feed. The data is in the form o

Solution 1:

Append --disable-web-security (at path C;...\chrome.exe) in chrome's exe properties preceded by a space.

More Elegant Answer :

Other solution will be on server side. Which is to create crossdomain.xml and clientaccesspolicy.xml file on server. It's structure is like:

crossdomain.xml:

<!DOCTYPE cross-domain-policySYSTEM"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"><cross-domain-policy><allow-http-request-headers-fromdomain="*"headers="SOAPAction,Content-Type"/></cross-domain-policy>

clientaccesspolicy.xml:

<?xml version="1.0" encoding="utf-8"?><access-policy><cross-domain-access><policy><allow-fromhttp-request-headers="SOAPAction"><domainuri="*"/></allow-from><grant-to><resourcepath="/"include-subpaths="true"/></grant-to></policy></cross-domain-access></access-policy>

Some of the tutorials are:

http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000469.html

http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html

Its specification is:

http://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/CrossDomain_PolicyFile_Specification.pdf

Other tutorials:

https://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx

Solution 2:

What you are trying to do, Is a cross domain request. A cross domain request is also called a JSONP request amongst many more others and has two restrictions:

The first is that it restricts you only to "GET" requests, meaning you cannot issue a "POST" request to the cross domain server.

The second is that you are very limited by the server, meaning that if the server won't allow, you cannot get any data.

I would suggest you to read more about cross domain request before trying to go through this.

Solution 3:

You are probably trying to execute an XMLHttpRequest to a domain that is different than your page is on, the browser will block this request. To allow the request you have to use CORS.

You can open the developer tools in Chrome (F12) and check for any error messages related to "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '[domainname]' is therefore not allowed access."

Solution 4:

Thank to Muhammad Imran, Barr J and Luuk Moret, I am finally able to solve my problem. It was the Cross domain request that's why it was not allowing me to get data. So what I did,

  1. I checked using test-cors.org the server to which I was sending request to see if CORS is configured or not. And the server was configured.
  2. Then I installed this plugin for chrome, "Allow-Control-Allow-Origin: *" This plugin allows to you request any site with ajax from any source. Adds to response 'Allow-Control-Allow-Origin: *' header and Whola!. That solved my problem.

I hope this would help someone else.

Post a Comment for "Get Data Out Of Json Array From External Url"