0

I referred this link, but with no luck. When I use the following link in the address bar, the browser shows json data.

http://xxxx.xxx.com:1234/products.json // Only a sample link

But when I try the following code,

 $.ajax({

                url : 'http://xxxx.xxx.com:1234/products.json',

                dataType: 'json',
                async: false,
                success: function(data) {

                alert( "test" ); 


                },
                error : function() {
                    alert("Sorry, The requested property could not be found.");
                }
            });

It always shows the error message. What is wrong in my method?

13
  • 1
    Have you run the JSON through a validator like JSON Lint, to check it is 100% valid? Commented Sep 4, 2013 at 15:44
  • do you control the content? Commented Sep 4, 2013 at 15:44
  • 4
    You cannot fetch content from other domains unless the other domain explicitly allows it, and that site probably doesn't. (The link doesn't work anyway.) Commented Sep 4, 2013 at 15:44
  • change your error handler to ` error: function (xhr, status, error) { alert("Error:" + status + ':' + error + ':' + xhr.responseText); }` Commented Sep 4, 2013 at 15:47
  • 1
    @Sharun that means the server you are requesting from doesn't support JSONP. If it also isn't doing CORS, then you're only option is to use something other than the browser to make the request (such as your server) Commented Sep 4, 2013 at 15:53

0

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.