So I am doing some testing with the food2fork api.
I seem to be getting a 404 forbidden. Have looked and cannot find anything that has worked. http://food2fork.com/about/api Code below
$(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. 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.