简体   繁体   中英

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>

您可以使用应用程序引擎的urlfetch库从另一台服务器(即您要从中获取值的博客)中获取URL。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM