function postmessage(){
var delayTime = [];

$.each(arr,function(key,val){
//回调函数有两个参数,第一个是元素索引,第二个为当前值
delayTime[key] = setTimeout(function() {
$("#postform").attr("action",val);
$("#postform").attr("target","_blank"); 
$("#postform").submit();
},2000)

//if (key > 28) return false;

//$.post(val, $("#postform").serialize());
});
}遍历数组,数组是n个url地址,然后向这些url提交表单同时提交的太多了,很卡想做个延时,怎么写啊?

解决方案 »

  1.   

    这样也是掩饰,延时有函数可使用,不要认为的去做一些无谓的操作
    <html>
    <head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
    function show(){
     alert("show!!");
    }$(function(){
      $('#mydiv').mouseover(function(){
      t = setTimeout("show()",2000);
     }).mouseout(function(){
      clearTimeout(t);
     });
    });
    </script>
    </head><body>
     <span id="mydiv">我是菜单</span>
    </body> 
      

  2.   

    我写的和fengyarongaa基本一样啊循环内怎么搞还是不清楚