forked from IBMHACK/IBMHACK.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
41 lines (28 loc) · 672 Bytes
/
main.js
File metadata and controls
41 lines (28 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var ing = ["onions","garlic"];
var fetch = function(ingr, callback){
var uri = "http://www.recipepuppy.com/api/?i=";
for (var i = 0; i < ingr.length; ++i){
uri = uri + ingr[i];
if (i !== ingr.length - 1) uri = uri + ",";
}
uri = uri + ""; // PAGES TODO
$.ajax({
type: "POST",
dataType: 'text',
url: uri,
crossDomain : true,
xhrFields: {
withCredentials: false
}
}).done(function( data ) {
console.log("done");
var nodeNames = [];
var html = JSON.parse(data);
if (callback) callback(html.results);
})
.fail( function(xhr, textStatus, errorThrown) {
alert(xhr.responseText);
alert(textStatus);
});
};
fetch(ing);