Ajax

64 views
Skip to first unread message

Massimiliano

unread,
Sep 26, 2011, 6:54:13 AM9/26/11
to google-appengine
Hi,
I'm trying to use Ajax but is not working. Could you please help me?

This is my code:
Python

class TextHandler(webapp.RequestHandler):
def get(self, domain):
finale =""
text = db.Query(FRASI).order('-date').filter('contatore >', int(domain))
for elemento in text:
if elemento.link:
finale = finale + "<a href=" + elemento.Glink + "> <img src=" + elemento.Tlink + "/><br></a> " + elemento.frase + "<br>"
else:
finale = finale + elemento.nick + ": " + elemento.frase + "<br>"
self.response.out.write(template.render('main1.html',{'finale':finale}))

Ajax in the <head>

<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","{{ AggLink }}",true);
xmlhttp.send();
}
</script>

Ajax in the <body>

<div id="myDiv" style="background: #1328A9">  Nuovi post </div>
<button type="button" onclick="loadXMLDoc()">Aggiorna</button>

--
Skype: massimiliano.pietroni

sergey

unread,
Sep 27, 2011, 3:04:41 AM9/27/11
to Google App Engine
Try to use |safe in you template after variable name.

On Sep 26, 1:54 pm, Massimiliano <massimiliano.pietr...@gmail.com>
wrote:
> Msn: massimiliano.pietr...@hotmail.it
> Sito:www.themaxbuddies.com<http://goo.gl/WoxEN>
> Ti serve dropbox?<https://www.dropbox.com/referrals/NTI4MzgyMjM5?src=ab_global8>

Max

unread,
Sep 27, 2011, 3:14:58 AM9/27/11
to google-a...@googlegroups.com
You mean:
{{ AggLink|safe }}.
Is this the right way?

Max

unread,
Sep 29, 2011, 11:14:15 AM9/29/11
to google-a...@googlegroups.com
Now I have this error:
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 344, in find_filter
    raise TemplateSyntaxError, "Invalid filter: '%s'" % filter_name
TemplateSyntaxError: Invalid filter: 'safe'

Matt Jibson

unread,
Sep 29, 2011, 11:35:00 AM9/29/11
to google-a...@googlegroups.com
You are using the old version of django, 0.96. You need to switch to django 1.2.

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/cF0btCvUZvcJ.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>

Max

unread,
Sep 29, 2011, 11:38:44 AM9/29/11
to google-a...@googlegroups.com
I don't know how can I do it.
I'm not an It. I have my code  and I have deploy it in the cloud. This is the error I see in the online app.
Have I to import something specific?

Matt Jibson

unread,
Sep 29, 2011, 1:34:17 PM9/29/11
to google-a...@googlegroups.com
Use the process below, and specify '1.2' is the version:
http://code.google.com/appengine/docs/python/tools/libraries.html#Django

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/google-appengine/-/-nF75G5s44YJ.

Reply all
Reply to author
Forward
0 new messages