举例:ajax.html
<html>
<head>
<meta charset="utf-8" />
<title>ajax test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
jQuery(function($){
$('button').click(function(){
$name = $(this).attr('name')
$('#out').empty().load('/ajax_deal/',{ name : $name })
})
})
</script>
<style type="text/css"></style>
</head>
<body>
<button id="btn-1" name="1">1</button>
<button id="btn-2" name="2">2</button>
<button id="btn-3" name="3">3</button>
<div id="out"></div>
</body>
</html>
设置下路由:url(r'^ajax_deal/$','jobs.views.ajax_deal'),创建名为jobs的app
/opt/django/webproject/jobs
处理函数:
def ajax_deal(request):
return HttpResponse("hello")
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)