zjm1126
zjm1126

Reputation: 35662

how to send a ajax not using open the webpage on google app engine

you know send a ajax you can use javascript lib like: jquery $.ajax or $.post ..

but this need to open the webpage

but how to send a ajax and get the ajax return value not using open the webpage on google app engine

thanks( i use python)

updated

class CounterHandler(BaseRequestHandler):
    def get(self):
        self.render_template('counters.html',{'counters': Counter.all()})

    def post(self):
        key = self.request.get('key')
        # Add the task to the default queue.
        for loop in range(0,2):
            a=taskqueue.add(url='/worker', params={'key': key},method="GET")

        self.redirect('/')

my mean is :

how to send ajax and get the return value using python(on gae), not using javascript ,

because i was using task queue (task queue can't add a task which want to send ajax).

updated2

1.i want to get the return value from a microblog like twitter,

2.so i have to send a ajax to the microblog for get the return value

3.i want to get the return string per hour , so i have to use task queue on google app engine

4.but task queue cant get the return string only use

taskqueue.add(url='/worker', params={'key': key},method="GET")

5.so i have to edit the worker hander like this :

class CounterWorker(BaseRequestHandler):
    def get(self): 
        self.render_template('ajax.html')

and the ajax.html is :

<script type="text/javascript">
    $.get("http:/www.digu.com/api", function(data){
      $.post("/save",{ajax:data})
    })
</script>

Upvotes: 0

Views: 268

Answers (1)

Saxon Druce
Saxon Druce

Reputation: 17624

You can use app engine's urlfetch library to fetch a url from another server (ie the blog you want to fetch a value from).

Upvotes: 1

Related Questions