var api_host = '';
$(function() {
function get_search_results(query_id) {
$.ajax({
data: '', // id search result
url: api_host+'/api/result',
type: 'GET',
success: function(response) {
console.log(response);
console.log("Everything finished, no errors");
},
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 401) {
console.log("Error 401");
}
if (jqXHR.status == 404) {
console.log("Not finished");
}
}
});
};
$('.sendButton').click(function() {
$.ajax({
url: api_host+'/api/search',
data: $('form').serialize(),
type: 'POST',
success: function(response) {
get_search_results(response); // или response['id'], зависит от формата ответа
},
error: function(error) {
console.log(error);
}
});
});
});
#!/usr/bin/env node
CoffeeScript = require("coffee-script");
CoffeeScript.register();
create_app = require("../app/application");
app = create_app();
app.listen(5000);
console.log("Application running on http://localhost:5000/");
console.log("(" + process.env.NODE_ENV + " mode)");
content[n] = element.content
api[element.api].forEach(function (apiElement, n) {
content[n] = {};
for (var i in element.content) {
content[n][i] = element.content[i];
}
content[n].content = apiElement;
});
var async = require("async");
// ...
var tasks = [];
if (price) {
tasks.push(function(callback) {
connection.query('UPDATE fotopovtory SET price="' + price + '" WHERE foto_id = "' + itemId + '";', callback);
});
}
if (type) {
tasks.push(function(callback) {
connection.query('UPDATE fotopovtory SET tipe="' + type + '" WHERE foto_id = "' + itemId + '";', callback);
});
}
async.parallel(tasks, function(err) {
if (err) throw err;
res.end();
});