Uncaught SyntaxError: Unexpected token ILLEGAL
May i know whats wrong in this.I am new to world of programing ..So if you help me it would be wonderful.The error comes on the line
arr[${i.count-1}][1]=${employee.email};
Awaiting for your response.The entire Code as follows..
$(function() {
var arr = new Array();
arr[0]=new Array(4);
arr[0][0]=sathis;
arr[0][1]=sathis@gmail.com;
arr[0][2]=namakkal;
arr[0][3]=21;
arr[1]=new Array(4);
arr[1][0]=ganesh;
arr[1][1]=gans@gmail.com;
arr[1][2]=karaikudi;
arr[1][3]=22;
arr[2]=new Array(4);
arr[2][0]=karthik;
arr[2][1]=karthik@yahoo.co.in;
arr[2][2]=trichy;
arr[2][3]=25;
var str="<table><tr><th>Name</th><th>Email</th><th>City</th><th>Age</th></tr><tr><td>";
$("#emp_name").change(function() {
var i=$(this).val();
str=str+arr[i-1][0]+"</td><td>"+arr[i-1][1]+"</td><td>"+arr[i-1][2]+"</开发者_运维知识库td><td>"+arr[i-1][3]+"</td><tr></table>";
$("#viewer").html(str);
alert(str);
});
});
You need quotes for strings.
For example, you need arr[0][0]='sathis';
instead of arr[0][0]=sathis;
Also, there's an easier way to do arrays:
arr[0] = ['sathis', 'sathis@gmail.com', 'namakkal', 21];
As [user:638452] pointed out, this could be a bad invisible character. Backspaced over an invisible character where Javascript told me the error was, and my code worked without modification.
精彩评论