My problem lies in displaying a message using Django. I have Python set up to allow users to input a message and send it to Google App Engine. My goal is to utilize this message for comparison in JavaScript in order to display the correct image.
Here is the JavaScript code snippet I am using:
var img = document.createElement("img");
img.src = "images/150.png";
if ({{messages.get().message}} == "hello"){
var src = document.getElementById("image1");
src.appendChild(img);
}
I'm having trouble with messages.get().message
as it seems to be throwing a parsing error. The Python code used to post messages in JSON format is shown below:
endef getJSONMessages(callback):
messages = db.GqlQuery("SELECT * FROM Message ORDER BY timestamp DESC LIMIT 1")
strlist = ""
for message in messages:
if len(strlist)>0:
strlist += ',' + message.asJSONString()
else:
strlist = message.asJSONString()
if callback=='':
return '[' + strlist + ']'
else:
return callback+'([' + strlist + ']);'
Any assistance regarding this issue would be greatly appreciated.