Py学习  »  问与答

Django 1.6.5中,我用jQuery Ajax从后台取数据,被403了

linandlif45 • 10 年前 • 5902 次点击  

代码如下:

 <html>
<head>
<meta charset=*utf-8*>
<title>blog</title>
{% load staticfiles %}
<script type="text/javascript" src="{% static "js/jquery-1.11.1.min.js"%}"></script>
</head>
<body>
<form id="form" method="post">
{% csrf_token %}
<input type="text" id="username" name="username" class="mws-login-username" placeholder="username"><br/> 
<input type="password" id="password" name="password" class="mws-login-password" placeholder="password"><br/>
<input type="button" value="Login" id="userLogin" class="btn btn-success mws-login-button">
</form>
<script type="text/javascript">
$(function(){
$(*#userLogin*).click(function(){
alert(*msg*);
$.ajax({
type: "POST",
url: "{% url *blog.views.xy_login*%}",
data: {username:$("#username").val(), content:$("#content").val()},
dataType: "json",
success: function(data){
alert(data); 
}
});
});
})

</script>
</body>
</html>
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/630
 
5902 次点击  
文章 [ 2 ]  |  最新文章 10 年前