2012-11-27 4 views
4

값을 삭제하는 동안 다음과 같은 팝업이 표시됩니다. jQuery Ajax를 사용하여 값을 삭제하고있다. 내가 사용하는 프로그래밍 언어는 python2.7하고 프레임 워크는 다음과 같이 1.3.2jQuery Ajax delete를 사용하여 삭제하는 동안 경고 받기

내 코드는 장고입니다 :

$.ajax({ 
    type: "DELETE", 
    url: window.location.pathname + id + '/data-centers/' + dc, 
    contentType: 'application/html; charset=utf-8', 
    data: { 
     dc : dc, 
    }, 
    success: function(){ 
     alert("success"); 
    } 
    etc... 

을 내가 자바 스크립트에서 다음 팝업을 받고 있어요 값을 삭제 확인하면 말 :

"This web page is being redirected to a new location. Would you like to resend 
the form data you have typed to the new location? 

그리고 아약스 헤더

I 수 있습니다 (이것은 다른 위치로 리디렉션하려고하지만 왜 몰라)은 다음을 참조하십시오

Connection Keep-Alive 
Content-Encoding gzip 
Content-Length 251 
Content-Type text/html; charset=iso-8859-1 
Date Tue, 27 Nov 2012 13:53:44 GMT 
Keep-Alive timeout=5, max=100 
Location http://www.test.com/403/test-403.html 
Vary Accept-Encoding 
Request Headers 
Accept */* 
Accept-Encoding gzip, deflate 
Accept-Language en-us,en;q=0.5 
Connection keep-alive 
Content-Length 12 
Content-Type application/html; charset=utf-8 
,

이것은 DELETE를 사용하려고 할 때만 발생합니다.

+5

403 (금지 된) 페이지로 리디렉션되고 있습니다. 서버/응용 프로그램/컨트롤러에서 http DELETE 동사를 권한을 부여하는 것이 해결책이라고 생각합니다. – jbl

답변

0

코드에 따라 아약스 경로가 잘못 되었기 때문에 오류가 발생할 수 있습니다. 또는 ajax 호출 HTML에 일부 리디렉션 문제가있을 수 있습니다. 경로가 적절하지 않은 경우이 도움이 될 수


$(location).attr('href'); 

$(document).ready(function() { 
    var pageurl = window.location; 
}); 

var currentpageURL = window.location.href; 

var currentpagepath = getAbsolutePagePath(); 

function getAbsolutePagePath() { 
    var pageurl = window.location; 
    var pathName = pageurl.pathname.substring(0, pageurl.pathname.lastIndexOf('/') + 1); 
    return pageurl.href.substring(0, pageurl.href.length - ((pageurl.pathname + pageurl.search + pageurl.hash).length - pathName.length)); 
} 

에 따라 그래서 당신은 가변적이고 다양한 종류로 설정할 수 있습니다 너

관련 문제