0
<!doctype html>
<html>
<head>
    <title>Parsing</title>
    <script type="text/javascript" src="jquery-2.1.0.min.js"></script>

</head>
    <script>
        alert("ciao");
        $.getJSON('', { get_param: 'value' }, function(data) { 

        });
    </script>

    <body >
        <p>ciao<p>
    </body>

</html>

With this code I want to parse this JSON:

asd'cp'pd'pcd'sp'sdp'dc

The browser console give me this error (I don't understand what it means):

XMLHttpRequest cannot load http://sath3g.altervista.org/index.php?get_param=value. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 

What is wrong?

3
  • 5
    Read about Same origin policy Commented Apr 8, 2014 at 13:01
  • In with way i can solve the problem? Can you help me? Commented Apr 8, 2014 at 13:04
  • Plus json/javascript hash keys may not contain spaces. Commented Apr 8, 2014 at 13:07

2 Answers 2

2

I think your are trying to do a cross domain ajax request.Browser will block the request because of Access-Control-Allow-Origin.

If you need to access the data from another domain i'll suggest you to use jsonp. But for that, the required server should bind the return data with a client side function.

Refer this.

Also you can try enabling cors in the ajax request.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you make me an example?
@user3485122 please check this demo jsfiddle.net/8VY52/239. Its an example for cors enabled server..
0

You can use crossDomain: true in jQuery ajax.
Check this link for details

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.