I am trying to use my github api, but it always return error. the same thing is happening for https://api.meetup.com/2/cities also.
I am very new to ajax please help.
$('.btn').click(function(){
$('.image').text("loading......");
$.ajax({
type:"GET",
url:"https://api.github.com/users/vivekpradhanC",
success: function(data){
alert("enter");
$('.image').text(JSON.stringify(data));
},
error: function(xhr, ajaxOptions, thrownError){
alert(xhr.responseText);
alert(ajaxOptions);
},
datatype:'jsonp',
});
});
You are requesting a remote URL in ajax, this might not be allowed because of Cross-Origin Resource Sharing policy, you maybe not allowed to access this URL throught Ajax.
Check this article https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS for more info.