将值推送到数组jquery

我在表单的开头创建了一个空数组

 var monthly_values = []; var i=0;  

在循环内部尝试实现以下代码….但是如果没有“alert”框,推送也不起作用,如果我删除“ready(function())”

 $prodline=500$ /// CGI script loops till 500 iterations  $(document).ready(function(){ i++; monthly_values.push("$premium$"); setTimeout(function() { alert("$premium$"); }, 1); });  $/prodline$//end of the iteration... 

我将值从循环推送到正在工作的数组。但我需要从警报框中删除警报框或至少确定..

整个代码在这里..

     PHP FILE - $licensee$       var monthly_values = []; var i=0;   // var monthly_values = []; // var i=0; function getbest (ambest, company, compcode) { document.comparisonform.AmBest.value = ambest; document.comparisonform.CompanyName.value = company; document.comparisonform.CompanyCode.value = compcode; document.comparisonform.OnClick=abc=window.open('','reason','width=700,height=500,left=20,top=20,scrollbars=yes'); document.comparisonform.target='reason'; abc.focus(); document.comparisonform.submit(); }      .loader { border: 16px solid #f3f3f3; border-radius: 50%; border-top: 16px solid #3498db; width: 120px; height: 120px; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; margin: auto; padding: 10px; } @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }    
$prodline=500$ $(document).ready(function(){ i++; monthly_values.push("$premium$"); setTimeout(function() { alert("$premium$"+"$company$"+"$product$"+"$healthcat$"+"$PremiumAnnual$"+"$Premium$"+"$rgpfpp$"+"$guar$"+"$policyfee$"+"$comp$"+"$prod$"+"$rowEvenOdd$"); }, 1); }); $/prodline$

$(document).ready(function(){ var len=monthly_values.length; var min_quote=monthly_values [0]; var max_quote=monthly_values [monthly_values.length-1]; window.location = 'http://loalhost/laravel/public/customised-quote?min_quote_val='+min_quote+'&max_quote_val='+max_quote; });

此代码应该没有问题,请检查下面的代码段。 你在你的HTML中包含jQuery吗?

 var monthly_values = []; var i=0; $(document).ready(function(){ i++; monthly_values.push("$premium$"); setTimeout(function() { console.log(monthly_values) }, 1); });