Here's the Ajax code:
jQuery.ajax({url: "http://api.tumblr.com/v2/blog/" + nonTumblrURL + "/info?api_key=WIHfFzkpSXJ4FOfzt3qBAhlleM09iSAtc2AFNAdViAeRPzAsMq&jsonp=getUserName", dataType: "jsonp"});
Here's the function:
function getUserName(data){
console.log(data.response.blog.name);
var username = data.response.blog.name;
if (username === "api" ){
//alert("You didn't enter anything.");
$('input.nonTumblrURL').val("You need to enter something here.");
return;}
$('#convertedURL').html("<em>Use </em><b> " + username + "</b> <em> for that Tumblr</em>");
}
The purpose here is to retrieve a Tumblr's username when a custom domain like "customdomain.com" is used instead of the standard "someone.tumblr.com". So, I use the Tumblr API to get the username.
When a blank value is sent in the Ajax call, it returns "api" so I trapped that in the function and placed a results message in #convertedURL
and works fine.
What I need is something that will trap a non-blank value that won't resolve in the Tumblr API. For example, "theagenda.nytimes.com" properly resolves to "nyt-agenda".
But, I need to trap something like "junkkkkk" (and others which are not a valid domains for Tumblr or otherwise) and replace the HTML in #convertedURL
with a message like "That's not a custom domain in use".
Thanks in advance for your help!