4

値を削除しようとすると、次のポップアップが表示されます。jQuery Ajax を使用して値を削除しています。私が使用するプログラミング言語は python2.7 で、フレームワークは Django 1.3.2 です。

私のコードは次のとおりです。

$.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...

値の削除を確認すると、JavaScript から次のポップアップが表示されます。

"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?

そして、Ajaxヘッダーには次のように表示されます(他の場所にリダイレクトしようとしていますが、理由はわかりません):

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 を使用しようとしたときにのみ発生します。

4

1 に答える 1

0

あなたのコードに基づいて、ajaxのパスが適切でないか、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));
}

これがあなたを助けるかもしれません

于 2013-01-07T09:41:39.013 に答える