I'm working on a project, and we use a lot of coding languages for different parts.
I've tried to simplify the problem as much as I can, and came up with the following JSfiddle.
The problem is, I have a JSON string which I want to pass on to a JavaScript function.
If I call it from JavaScript, it's OK. But when I call it with a onmouseover
, HTML throws the error
Uncaught SyntaxError: Invalid or unexpected token
JavaScript Code:
function test123(obj, e, lookupx){
console.log(lookupx);
}
test123(this, event, '{"mt:assetsys:assetuapr":{"assetmat":"material","assettag":"tag"}}');
HTML:
<div>
First check the console, direct calling with js string is ok.<br>
Then:<br>
<a href="#" onmouseover="test123(this, event, '{"mt:assetsys:assetuapr":
{"assetmat":"material","assettag":"tag"}}');">hover this
</a>
<br>
And an error occurs
</div>
Could someone explain what the difference is between the two cases?
The onmouseover vs
The direct calling to the function.