问题描述
我试图做使用免费域名API的API域名可用性搜索。
I am trying to do a domain availability search using an API from free domain API.
在我创建一个帐户,它表明:
After i create an account, it shows:
**Make a REST request using this URL:**
http://freedomainapi.com/?key=11223344&domain=freedomainapi.com
和看在文档页面,它只有:
And looking in the documentation page, it has only:
请求 http://freedomainapi.com?key=YOUR_API_KEY&domain=DOMAIN_NAME
结果:
{
"status": "success",
"domain": "freedomainapi.com",
"available": false
}
我很新的API的...
I am very new to APIs...
我需要的是显示一个域名搜索框,当用户输入,它应该返回结果。
What I need is to show a domain search box, and when the user enters, it should return with result.
它声称显示领域的建议为好。我希望它也将正常工作。
It claims to show domain suggestions as well. I hope it will also work.
推荐答案
使用jQuery和JSONP代理
Using jquery and a jsonp proxy
$.ajax({
type: 'GET',
url: "https://jsonp.nodejitsu.com/?callback=?",
data: {url: 'http://freedomainapi.com?key=14ejhzc5h9&domain=freedomainapi.com'},
dataType: "jsonp",
success: myfn
});
function myfn(data) {
console.log(data);
}
您必须使用代理,因为跨域JSON是不允许的。
you have to use the proxy because cross domain json is not permitted
编辑:
我做了更新,以显示结果的div(字符串化)
编辑#2:我创建了该网站测试关键,你必须使用你自己的
EDIT #2: i created a test key on that site, you have to use your own
编辑#3:而且有你的组合: http://jsfiddle.net/mp8pukbm/4/
EDIT #3: and there's your combo: http://jsfiddle.net/mp8pukbm/4/
这篇关于从API获取结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!