在如何向后端请求数据或后请求方面需要帮助

时间:2018-09-12 04:45:19

标签: javascript jquery backend web-frontend

我需要协助来发布和从后端检索数据。现在,代码是针对HTML的,但是我需要更改命令才能为服务器工作,如何更改它们以获取数据并将数据发布到服务器。 只是在下面添加了代码,以显示我应该对后端进行哪些更改。 只需要那些

function moveClawDown(){
    grabber_arm.animate({ top: -220 }, 2000, function(){
        // show the prize box
        // check if user has won
    if( win_on == number_of_tries )
            prize.show().css('background-image', 'url(./img/item_1.png)');
        setTimeout(moveClawUp, 250);
    });
	
}

// function to move the claw up
function moveClawUp(){
    grabber_arm.animate({ top: -800 }, 2000, function(){

        // check if user has won
        if( win_on != number_of_tries ){

            grabber_arm.animate({ left: '50%' }, 1000 );
            setTimeout( function(){ restart_btn.show() }, 1000);
            number_of_tries++;
        }
        else{
            // user has won - get random prize
            setTimeout( function(){
                win_box.html("<div class=\"win-message\"><p>YOU'VE WON!</p><img src=\""+products[random_prize][2]+"\"><p>"+products[random_prize][1]+"</p><button>Checkout</button></div>").show();
            }, 1000);
        }
    });
}

// calculates how far the claw has moved
function calculateDistance(){
    claw_position = grabber_arm.offset().left - grabber_wrapper.offset().left;
    claw_position = Math.round(claw_position);
}

// function for returning a random number
function getRandomNumber(numberRange) {
   return Math.floor(( Math.random() * numberRange ) + 1);
}

// function to add images of prizes in random places
function addPrizes(){
    prizes_wrapper.append("<img class=\"prize\" src=\"img/gift.jpg\" />");
}

0 个答案:

没有答案