Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My goal is to use a photon and by click on a button some data is sent to the photon via the cloud. However, at the same time I would like to go to another page as well. The problem is that when I try to press the button, it doesnt even go to the other page. Im not sure yet if the data is even being sent (haven't tested), but it should go to another page. Any help is much appreciated.

    <!DOCTYPE html>
<html>

<body>

<input id="Memory Button" type="button" value="Memory Game" onclick="return myFunction1("setGame"),myFunction2()"/>

<script language="javascript" type="text/javascript">



function myFunction1(objButton)
{
    var deviceID = "1f0026001847353236343033";
    var accessToken = "edc90d3d0f4048681a946f75a7bbe221ad7e1110";
    var baseURL = "https://api.particle.io/v1/devices/";

    varname=objButton;
    requestURL= baseURL + deviceID + "/" + varName + "/?access_token=" + accessToken;
    $.post( requestURL, { params: varName , access_token: accessToken });
}

function myFunction2()
{
    window.location.href = 'http://twin-cities.umn.edu/';
}

</script>


</body>

</html>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
186 views
Welcome To Ask or Share your Answers For Others

1 Answer

onclick should be onclick="myFunction1('setGame');myFunction2()" like

<input id="Memory Button" type="button" value="Memory Game" onclick="myFunction1('setGame');myFunction2()"/>

total

<!DOCTYPE html>
<html>

<body>

<input id="Memory Button" type="button" value="Memory Game" onclick="myFunction1('setGame');myFunction2()"/>

<script language="javascript" type="text/javascript">



function myFunction1(objButton)
{
    var deviceID = "1f0026001847353236343033";
    var accessToken = "edc90d3d0f4048681a946f75a7bbe221ad7e1110";
    var baseURL = "https://api.particle.io/v1/devices/";

    varname=objButton;
    requestURL= baseURL + deviceID + "/" + varName + "/?access_token=" + accessToken;
    $.post( requestURL, { params: varName , access_token: accessToken });
}

function myFunction2()
{
    window.location.href = 'http://twin-cities.umn.edu/';
}

</script>


</body>

</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...