私はWeb開発を学んでおり、RESTAPIを介してMongoLabでホストされているMongoDBデータベースにクエリを実行するためのajaxリクエストを作成しようとしています。私のコードは非常に単純ですが、ajaxリクエストが常にエラーになる理由がわかりません。ヘルプ?
<doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.min.js"></script>
<title>Data Viewer</title>
</head>
<body>
<form id="the_form" method="post">
<input type="submit" value="Go" />
</form>
<script>
$(function() {
$('#the_form').submit(function() {
$.ajax({
url: 'https://api.mongolab.com/api/1/databases/omnitor-android/collections/logs?apiKey=[some API key in here]',
type: 'GET',
success: function(data) {
alert(data);
},
error: function() {
alert("boom");
}
});
});
});
</script>
</body>
</html>