我们已经看过了与这个问题有关的其他条目。但这似乎解决不了我的问题。我试图加载一个页面,并且有一个js函数,它加载一个试图访问部署在本地的应用程序的graph.when,它运行良好,没有任何错误。但是,当尝试访问链接(部署在服务器中的同一应用程序的页面)时,我们将获取未定义的错误TypeError: toLowerCase属性
function show_vis(tower, cluster, product,region,all_application, flag)
{
document.getElementById('heat-chart').innerHTML='';
var appList = [];
var app_corr = [];
var indexarr = new Array();
// second issue fixed....
tower = encodeURIComponent(tower);
cluster = encodeURIComponent(cluster);
product = encodeURIComponent(product);
region = encodeURIComponent(region);
flag = encodeURIComponent(flag);
$.get("Dashboard_Core_Analysis.jsp?tower=" + tower
+ "&cluster=" + cluster +"®ion="+region+ "&product=" + product + "&default=" +flag, function(data, status) {
appList=data.trim().split('\r\n');
if(appList.length != 1 ){
for(var i = 1 ; i < all_application.length ; i++)
{
for(var j = 0 ; j < appList.length ; j++)
{
**if (all_application[i][1].toLowerCase() == appList[j].toLowerCase())**
{
indexarr.push(all_application[i][0]);
app_corr.push(all_application[i][1]);
}
}
}
buildHeatMap(app_corr, indexarr, flag);
}
else
{
document.getElementById('heat-chart').innerHTML='<div style="Margin-top:50px; text-align:center;">No Data to Display</div>';
document.getElementById('tag-cloud').innerHTML='';
document.getElementById('area-chart1').innerHTML='';
document.getElementById('area-chart2').innerHTML='';
}
}); }我甚至调试了代码,并保持了一个警报,以检查是否正在填充all_application & appList的值。这些值正在被很好地填充。以下是值
all_application值
index,application_name,
1,Friday Daily Jobs WK1,
2,Monday Additional Jobs,
3,Monday Daily Jobs,
4,Non Daily Jobs,
5,NonBATCHNDC Daily Jobs,
6,Others,
7,Tue-Fri Daily,appList值
Monday Daily Jobs,Non Daily Jobs,Tue-Fri Daily,Friday Daily Jobs WK1,Monday Additional Jobs,NonBATCHNDC Daily Jobs,Others上面是被调用的函数,当高亮显示的行被调用时,它会加载一个graph.In --上面的方法--应用程序通过一个未显示的TypeError。
当应用程序在本地部署到tomcat服务器中时,相同的代码可以正常工作。我不知道缺了什么。在这方面的任何帮助都是非常感谢的。
发布于 2016-03-15 10:24:23
根据问题注释中的讨论,问题是数据是从csv文件中提取的,该文件有空空格和空行,这导致数组添加了一个空值。
一些从csv提取数据的库或手工代码不检查空行,这可能会导致问题中所见的问题,因此您必须确保要么修剪csv文件,要么使用检查空行的代码。
https://stackoverflow.com/questions/35985014
复制相似问题