作者levicwsn (小泆)
看板Ajax
标题[问题] javascript 未定义
时间Fri Jun 26 22:47:56 2009
我写了一个function 如下 这个function的功能是要能够每5秒 用ajax 执行rt_bet.php
一起传的参数还有二个html 的 <select> 的值 document.all.rt_form_server.value
与 document.all.rt_form_type.value;
执行的功能没有问题
但是当网页要做切换的时候
因为新的页没面有这两个select所以会出现错误:
"ss未被定义"
请问该怎麽处理才能解决这个错误呢
var loop;
function bet_loop(server,type)
{
if(busy==0)
{
alert(444);
var postData='';
postData ="&server="+server+"&type="+type;
sendUrl_eval("rt_bet.php",postData);
}
if(busy==3)
{
alert(111);
clearTimeout(loop);
return;
}
else
{
alert(333);
var ss=document.all.rt_form_server.value;
var tt=document.all.rt_form_type.value;
var undefined;
alert(typeof(ss));
if(typeof(ss)==undefined)
{
alert(000);
return;
}
loop=setTimeout('bet_loop(ss,tt)',5000);
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.126.200.190
1F:推 chph:没看到你的呼叫点在哪 06/26 23:41
2F:推 ybite:1. document.all.id => document.getElementById('id') 06/28 13:34
3F:→ ybite:2. 如果你只是想知道某一个id的物件有没有在网页之中 06/28 13:35
4F:→ ybite: try if (document.getElementById('id')) 06/28 13:36
5F:→ ybite: (因为它会在找不到物件时回传null) 06/28 13:37