Unexpected Token ILLEGAL Javascript Error in Google Chrome

I get javascript error (prototype.js): Unexpected ILLEGAL token in this line of code:

newFriend = new friend( response[0] .@items [0]._id, response[0] .@items [0]._nickName, response[0] .@items [0]._profilePicture, response[0] .@items [0]._tagLine, response[0] .@items [0]._isInvite, response[0] .@items [0]._confirm ); 

The response object is as follows:

 [{"@type":"[Lcom.photoviewer.common.model.ThinUser;","@items":[{"_id":"000.060318.05022007.00263.0067ur","_nickName":"siraj","_country":null,"_currentStorageLimit":5000000000,"_currentStorage":0,"_currentFileCount":0,"_profilePicture":null,"_tagLine":null,"_membershipLevel":0,"_isRejected":false,"_isInvite":false,"_confirm":false,"_verifiedOn":1170716666000}]}] 

This only happens in the Google Chrome browser and possibly in other webkit browsers. It works great in Firefox.

+4
source share
2 answers

Try this instead:

 newFriend = new friend( response[0]["@items"][0]._id, response[0]["@items"][0]._nickName, response[0]["@items"][0]._profilePicture, response[0]["@items"][0]._tagLine, response[0]["@items"][0]._isInvite, response[0]["@items"][0]._confirm ); 

I am sure @ gives you problems.

For strange characters, it is always recommended to use the notation ["@items"] instead of the notation (period) .@items .

+8
source

Property names containing @ and dot notation are not compatible in Chrome. Use a square notation bracket (you already do when building an object).

0
source

Source: https://habr.com/ru/post/1299680/


All Articles