我想創建一個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