Skip to content
Advertisement

SyntaxError javascript php

This is a heart with a wishlist, I want to add the product to my wishlist.

I have a syntax error in the console

Uncaught SyntaxError: expected expression, got '}'

Dreamweaver shows me no errors

JavaScript

HTML output

JavaScript

php output with html (need to ajax)

JavaScript

Advertisement

Answer

Not having clarity over the code, it is somewhat difficult to tell the main cause of the error, as according to the error you are getting is

Uncaught SyntaxError: expected expression, got '}'

There is a code of block that is ending with these curly braces }

Also, you need to escape characters to make your code work properly.

JavaScript

The above code produces this HTML code

JavaScript

You need to escape characters(‘) to work around single quotes(‘) that is in your PHP code.

JavaScript

Here adding ' helps in formatting parameters correctly.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement