jQueryでクロスドメインのjson取得(JSONP)
<html> | |
<head> | |
<title>jsonp/jquery test</title> | |
</head> | |
<body> | |
<input type="text" id="url" style="width:300px;" value="http://blog.setunai.net/"> | |
<input type="button" id="run" value="test"> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
(function ($) { | |
var api = 'http://api.b.st-hatena.com/entry.count?callback=?'; | |
$('#run').click(function (){ | |
var url = $('#url').val(); | |
$.getJSON(api, {'url': url}).then( | |
function (cnt){ | |
alert(cnt); | |
}, | |
function (){ | |
alert('error dayo'); | |
} | |
); | |
}); | |
})(jQuery); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment