I am new here and I am using the API to build an app for a class project. I am using jQuery to perform the queries to the database but they fail in the code while the json data is displayed when I simply input the whole query string into a browser. Can somebody help me?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>GiantBomb</title>
</head>
<body>
<input type="text" placeholder="Game" id="game"/>
<input type="button" value="Search" id="search"/>
<script type="text/javascript" src="jqtouch/jqtouch/jquery.1.3.2.min.js"></script>
<script src="title.js"></script>
</body>
</html>
var api = "http://www.giantbomb.com/api/search/?api_key=";
var api_key = "";
var query = "&query=";
var format = "&format=json";
$("#search").click(function() {
var game = $("#game").val();
console.log(game.split(" "));
$.ajax({
type: "GET",
url: api + api_key + query + "uncharted" + format,
async: true,
jsonpcallback: "",
contentType: "application/json",
dataType: "jsonp",
success: function(response) {
console.log(response);
}
});
});
I use the same $.ajax() method with themoviedb and it works fine. However, I am getting an error saying Unexpected token ":". What am I doing wrong? Any help appreciated.
Log in to comment