Basically, you are trying to do it too fast. Wrap your function with $(document).ready(...)
.
$(document).ready(function() {
var url = 'http://api.themoviedb.org/3/',
mode = 'search/movie',
input,
movieName,
key = '?api_key=api key here';
$('button').click(function() {
var input = $('#movie').val(),
movieName = encodeURI(input);
$.ajax({
url: url + mode + key + '&query='+movieName ,
dataType: 'jsonp',
success: function(data) {
console.log(data);
},
error: function (request, status, error) {
alert(status + ", " + error);
}
});
});
});
<input id="movie" type="text" /><button>Search</button>