function calc_handle(item1, item2, price1, price2, weight1, weight2) {
    console.dir(item1);
    console.dir(item2);
    console.dir(price1);
    console.dir(price2);
    console.dir(weight1);
    console.dir(weight2);

    if (!isNaN(price1) || !isNaN(price2) || !isNaN(weight1) || !isNaN(weight2)) {
        // var item1_byWeight = Number(price1) / Number(weight1);
        // var item2_byWeight = Number(price2) / Number(weight2);
        //
        // if (item1_byWeight < item2_byWeight) {
        //     var difference = Number(item2_byWeight) - Number(item1_byWeight)
        //     console.log(item1 + "is cheapter by " + difference);
        // } else {
        //     var difference = Number(item1_byWeight) - Number(item2_byWeight)
        //     console.log(item2 + "is cheapter by " + difference);
        // }

        // send_total(item1, item2, price1, price2, weight1, weight2);
    } else {
        alert("You entered wrong format.");
    }
}

function send_total(item1, item2, price1, price2, weight1, weight2) {
    x = new XMLHttpRequest();
    x.open("GET", '/calculate_total?param1=value1&param2=value2', true);
    x.send();
}
//
// var oReq = new XMLHttpRequest();
// oReq.onload = function (e) {
//     results.innerHTML = e.target.response.message;
// };
// oReq.open('GET', e.target.dataset.url + '?' + new Date().getTime(), true);
// oReq.responseType = 'json';
// oReq.send();
//
//
// http.open("GET", url+"?"+params, true);
// http.onreadystatechange = function()
// {
//     if(http.readyState == 4 && http.status == 200) {
//         alert(http.responseText);
//     }
// }