我是新的django和jquery,我是searching for a 'hello world' sample for jquery
使用django1.3,其中hello世界从服务器返回到客户端的字符串/ json当用户按下按钮时或者在加载页面时。如何从Django模板中的Jquery脚本调用python函数
注:我正在使用django1.3和python 2.7。这是一个非常基本的问题。
我成功地显示了一个字符串“这是JQuery的Hello World”没有任何视图函数(只使用jquery)。但我不知道如何使用jQuery函数的视图函数 如果有任何人有想法请在advance.om模板 帮助me.Thanks我尝试使用下面的代码片段。
urls.py
(r'^hellofromserver/$',views.test),
def test(request):
if request.method == 'GET':
json = simplejson.dumps('hello world!')
return HttpResponse(json, mimetype = 'application/json')
jqueyhelloserver.html:
<html>
<head>
<title>jQuery Hello World</title>
<script type="text/javascript" src="{{STATIC_URL}}js/jquery-1.2.6.min.js"></script>
</head>
<body>
.....
<script type="text/javascript">
# how can I get'hello world' from test function(What is the sytax )
</script>
<div id="msgid">
</div>
</body>
</html>
我怎么能调用的函数 '测试',并从jQuery的 'hellofromserver'(从模板)?
我只需要知道如何jQuery的通信服务器? – Jisson