I want send to data to DETAILVIEW with Ajax but I have this error :
[HTTP/1.0 405 METHOD NOT ALLOWED 5ms
HTML :
<a href="#" onclick="goto_confirm('{% url 'dmde' dmde.eater %}')" ><b> Eat </b></a>
JS :
function goto_confirm(url){
alert(url);
var confirmation;
if(confirm("Are you sure ?"))
confirmation = true;
else
confirmation = false;
$.post("http://localhost:8000"+url,{"confirm": confirmation});
return false; //pour ne pas revenir au début de la page
}
The url is good, I checked it in terminal and in console js.
DETAIL VIEW :
def dmde(request,leater):
dmde = Announce.objects.get(eater=leater)
if(request.method == "POST"):
confirmation = self.request.POST.get("confirm")
print("aaaaaaaaaa : "+confirmation)
sup = confirmation
return render(request,"le_site/dmde.html",locals())
and the url :
url(r'^dmde-(?P<leater>[^/]+)$', 'dmde', name="dmde"),
I think the process is different because the url is dynamic..
您的DetailView不允许POST。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.