Does anyone know why the ajax statement here won’t accept the ‘-‘ symbol. I’ve had trouble with this in the past and had to change a lot of things in the backend of my site to send the “_” instead and it worked. Is there a way to make the ajax script accept the ‘-‘ sympbol?
$("#events").append("<img src='"+data[i].event-image+"'></a>");
This code is part of an ajax call to get some JSON data that my website is sending out. “event-image” is the name of my field. The consol throws an error saying can’t find “image”. So the dash is making the code ignore the first part “event-“. Any thoughts on how I could rectify this, other than changing the field on my site to be “_”. Let me know, thanks!
-is used for subtraction. You can do it like this though:variable.propertyis equivalent tovariable["property"]in javascript.