[英]Why am I getting 404 Forbidden with a JSON P api?
So I am doing some testing with the food2fork api. 所以我正在用food2fork api做一些测试。
I seem to be getting a 404 forbidden. 我似乎被禁止使用404。 Have looked and cannot find anything that has worked.
看过,找不到任何有效的方法。 http://food2fork.com/about/api Code below
http://food2fork.com/about/api下面的代码
$(document).ready(function() {
$("#button").click(function(event) {
event.preventDefault();
var searchTerm = $("#input").val();
showResults(searchTerm);
});
function showResults(searchTerm) {
$.ajax({
key: "xxxx",///api key
type: "GET",
dataType: 'jsonp',
url: "http://food2fork.com/api/search",
q: searchTerm,
success: function (data) {
alert('success');
}
});
}
});
The q
and key
properties of the object you're passing to $.ajax
are ignored because they're invalid. 传递给
$.ajax
的对象的q
和key
属性将被忽略,因为它们是无效的。 It should be part of the request data. 它应该是请求数据的一部分。
Try this instead: 尝试以下方法:
$.ajax({
type: "GET",
data: { q: searchTerm, key: 'yourKey' },
dataType: 'jsonp',
url: "http://food2fork.com/api/search",
success: function (data) { alert('success'); }
});
See Documentation 请参阅说明文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.