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][email protected];
arr[0][2]=namakkal;
arr[0][3]=21;
arr[1]=new Array(4);
arr[1][0]=ganesh;
arr[1][1][email protected];
arr[1][2]=karaikudi;
arr[1][3]=22;
arr[2]=new Array(4);
arr[2][0]=karthik;
arr[2][1][email protected];
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);
});
});
This error can occur for a number of reasons, but is typically caused by a typo or incorrect code. Luckily, the SyntaxError: Unexpected token error is relatively easy to fix. In most cases, the error can be resolved by checking the code for accuracy and correcting any mistakes.
The "Uncaught SyntaxError: Unexpected token" occurs for multiple reasons: Having a <script /> tag that points to an HTML file instead of a JS file. Getting an HTML response from a server where JSON is expected. Having a <script /> tag that points to an incorrect path.
The error Uncaught SyntaxError: Unexpected token < is most commonly caused by your site's code referring to an asset that is no longer available. Most commonly, this is due to a filename change in assets generated during your build.
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', '[email protected]', 'namakkal', 21];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With