Skip to content Skip to sidebar Skip to footer

How Do I Correctly Include A Dash In An Object Key In Javascript?

When I try to use a code like this: jQuery.post('http://mywebsite.com/', { array-key: 'hello' }); I get this error: Uncaught SyntaxError: Unexpected token - I tried surround

Solution 1:

jQuery.post("http://mywebsite.com/", {"array-key": "hello"});

should be correct. If this doesn't work, the issue is not with your request.


Post a Comment for "How Do I Correctly Include A Dash In An Object Key In Javascript?"