我打算发送一份JQuery的评论表,
html表单
<div>
<h4>Comments</h4>
<form method="POST" id="createComment"> {% csrf_token %}
<textarea class="form-control" id="commentContent" rows="5" name='comment'></textarea>
<br>
<button type="submit" id="commentBtn" class="btn btn-primary">Post Your Comment</button>
</form>
</div>
js
<script type="text/javascript" src="/static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/static/js/jquery.csrf.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var article_id = {{ article.id }};
var page_number = {{ page.number }};
$("#commentBtn").click(function(){
var comment =$("#commentContent").val();
var param = {"article_id":article_id, "content":comment};
$.post("/article/comment/create/", param, function(data){
var ret = JSON.parse(data);
if (ret["status"]=="ok") {
$("#commentContent").val("");
window.location.href="/article/detail/{{ article.id }}?page_number={{ page.num_pages }}" \\change to the final page
}else{
alert(ret["msg"]);
}
});
})
});
</script>
然而,当按下提交按钮时,我的页面无法正常工作错误:
This page isn’t working
If the problem continues, contact the site owner.
HTTP ERROR 405
我仔细检查了导入js,但没有发现任何问题。
我怎么能解决这样的错误?