尝试学习Dajax,因此决定尝试示例。但我还是坚持使用“乘法”的例子。我不知道出了什么问题。下面是代码。
Ajax.py:(它被放在“博客”应用中)
from dajax.core import Dajax
from dajaxice.core import dajaxice_functions
def multiply(request, a, b):
dajax = Dajax()
result = int(a) * int(b)
dajax.assign('#result','value',str(result))
return dajax.json()
dajaxice_functions.register(multiply)index.html:
{% load dajaxice_templatetags %}
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Blog</title>
{% dajaxice_js_import %}
<script type="text/javascript" charset="utf-8">
function calculate(){
Dajaxice.blog.multiply(Dajax.process,{'a':$('a').value,'b':$('b').value})
}
</script>
</head>
<body>
<input type="text" name="a" value="5" id="a"> x
<input type="text" name="b" value="6" id="b"> =
<input type="text" name="result" value="" id="result">
<input type="button" name="caculate" value="Let's Multiply!" id="caculate" onclick="calculate()">
</body>
</html>发布于 2011-06-02 16:05:05
首先,您应该正确地使用install dajaxice。然后,如果你正在使用Dajax,你也应该使用install Dajax。
阅读您的代码似乎表明dajaxice安装正确,但是您还没有安装Dajax,或者(至少)您还没有链接您的dajax风格的js。
如果你正在使用Dajax (你正在使用Dajax),你应该在Prototype、jQuery、Dojo或mootols之间选择一个框架,并将它添加到你的页面中,你还需要将framework.dajax.core.js链接到你的页面。
剩下的安装似乎已经完成了。
https://stackoverflow.com/questions/6207823
复制相似问题