开发者

Some Pyramid + AJAX (Jquery) questions

  1. In my Pyramid package directory, if I create a file calle开发者_开发知识库d somefunction.py and I want to call this function using $.post, what URL would I specify to call this function?

  2. If I have a view function called aview created in views.py, can I call this function by simply referring the $.post url as /aview/.

(script files reside in the static folder)


In both cases you have to write the proper routing configuration that maps the view (that has to contain the function you want to call) to a given url. You even have a xhr parameter to further customize the request [1]. I should clarify btw that I'm more a dispatcher than a traversal guy so my answer applies to that style of configuration

[1] http://docs.pylonsproject.org/projects/pyramid/1.0/api/config.html#pyramid.config.Configurator.add_route

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜