我想创建一个ajax函数,当被调用时返回信息到新创建的模态,可以帮我找出问题所在?,我得到错误“not found”每当我尝试访问有问题的URL时,我都会添加我的终端和所有相关文件的屏幕截图。Django -Ajax请求错误:找不到
views.py
@require_POST()
def form_create(request, model):
if request.method == "POST":
return HttpResponse("the model requested is")
urls.py
url(r'^forms/(?P<model>[\W-]+)/$','.views.form_create'),
Ajax调用在HTML模板
$.ajax({
url: "/forms/"+model+"/",
type: "POST",
cache: false,
success:
function(result){
$("#myModalLabel").html(result);
$("#companyModal").modal("show");
},
error:
function(xhr){
alert("Error: " + xhr.statusText);
return false;
}
});
你设置你的DEBUG =真? – catherine 2013-03-20 02:19:10
当然,我将它设置为True – Leonardo 2013-03-20 13:34:42
因为你的访问后,在阿贾克斯 – catherine 2013-03-20 14:51:45