开发者

How to customize display url after jquery POST?

I'm using Freebase Suggest, a JQuery search form:

<script type="text/javascript">
  $(function() {
    $("#game-search").suggest({type:'/games/game'}).bind("fb-select", function(e, data) {
    $("#game-id").val(data.id);
    $("#game-name").val(data.name);
    });
  });
</script>

<form name="input" action="/game" method="post">
  <input class="search-box" type="text" id="game-search"/>
  <input type="hidden" name="game_id" id="game-id" />
  <input type="hidden" name="game_name" id="game-name" />
  <input class="button" value="Go" type="submit"/>
</form>

This POST will return a page that displays game data. But I want the display url to be the permalink to this page. Right now, no matter what game is returned by searching, the url is foo.com/game, but the permalink is foo.com/game/id/mid (id and mid are reference ids).

In my Handler, I return using:

self.re开发者_Go百科sponse.out.write(template.render(path, 
                                        template_values, 
                                        debug=DEBUG))

I suspect there is a way to redirect as well but am not familiar with how.

UDPATE: doesn't seem to be clear what I am trying to ask/do. The POST passes an id via JQuery to the handler. The path for the POST is /game. I want the result page to display the URL /game/id/mid, basically I want to construct and display the permalink. Maybe this is as simple as constructing the Game object in the POST, and then redirecting to a GET (using the permalink URL structure), and then the GET renders the template.


first you should configure the app.yaml:

- url: /game/(.*?)/(.*?)
script: game/yourgame.py

then in your yourgame.py redirect the post to permalink url:

self.redirect('/game/your permalink url')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜