Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: getJSON request not working

Tags:

jquery

getjson

I am trying to access data using getJSON function of jquery but not able to succeed.

This is my js file:

$(document).ready(function(){
  $("button").click(function(){

    $.getJSON( "https://www.bitstamp.net/api/eur_usd/", function( data ) {
    alert(data);
    });
  });
});

Can anyone help me in getting this work?

Will really appreciate.

like image 449
user2206724 Avatar asked Dec 25 '22 17:12

user2206724


1 Answers

try to have error message in ajax call

$(document).ready(function() {
        $("button").click(function() {

            $.getJSON("https://www.bitstamp.net/api/eur_usd/", function(data) {
                    alert(data);
                }
                .error(function(xhr) {
                    alert(xhr)
                })
            );
        });
    });

Note: Xhr.responseText will provide you the stack trace of error, it returns in the html format

like image 137
Krishna Avatar answered Feb 11 '23 06:02

Krishna