Closed marti1125 closed 7 years ago
You might want to try this snippet:
jQuery.ajax({
url: 'https://coderwall.com/' + jQuery('#username').val() + '.json?callback=?',
dataType: 'JSONP',
success: function(response) {
// you might want to dump the response to firebug or the chrome console
// console.debug(response)
jQuery('#result').append('<h1>' + response.data.name + '</h1>');
// add rest of your code here
},
error: function(response) {
alert('Username not found');
}
});
By the way, try to avoid multiple var's in the same scope..
var username = val.username,
name = val.name,
location = val.location,
github = val.accounts.github;
Or even better, as you already have the response object: Don't shift around values if you don't have to. You can access all the values by:
alert(response.data.name);
alert(response.data.location);
// and so on..
@eremit thanks! Happy New Year :tada:
var search = $("#username").val();