发送数据到硬件并转到另一个网页? [英] Send data to Hardware and go to another webpage?
本文介绍了发送数据到硬件并转到另一个网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<!DOCTYPE html>
< html>
< body>
< input id =Memory Buttontype =buttonvalue =Memory Gameonclick =return myFunction1(setGame),myFunction2()/>
< script language =javascripttype =text / javascript>
函数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});
}
函数myFunction2()
{
window.location.href ='http://twin-cities.umn.edu/';
}
< / script>
< / body>
< / html>
解决方案
onclick
onclick =myFunction1('setGame'); myFunction2() like
< input id =Memory Buttontype =buttonvalue =Memory Gameonclick =myFunction1('setGame'); myFunction2()/>
总计
<!DOCTYPE html>
< html>
< body>
< input id =Memory Buttontype =buttonvalue =Memory Gameonclick =myFunction1('setGame'); myFunction2()/>
< script language =javascripttype =text / javascript>
函数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});
}
函数myFunction2()
{
window.location.href ='http://twin-cities.umn.edu/';
}
< / script>
< / body>
< / html>
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>
解决方案
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>
这篇关于发送数据到硬件并转到另一个网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文