Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught SyntaxError: Unexpected token ILLEGAL

Tags:

jquery

token

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);
    });


});
like image 736
sathis Avatar asked May 18 '10 07:05

sathis


People also ask

How do I fix unexpected token error?

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.

What does it mean by uncaught SyntaxError unexpected token?

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.

What does uncaught SyntaxError mean?

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.


1 Answers

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];
like image 114
that person Avatar answered Nov 15 '22 05:11

that person