从具有302状态的POST获取响应

Get response from POST with 302 status

本文关键字:POST 获取 响应 状态      更新时间:2023-09-26

jQuery文件上传:

$('#fileupload').fileupload({
    xhrFields: {withCredentials: true},
    url: 'http://URL/images/pre/',
    add: function (e, data) {
        var that = this;
        $.ajax({
            type : 'get',
            url : 'http://URL/images/pre/',
            dataType : 'jsonp',
            jsonp : 'jsonp',
            success : function(result) {
                url = result.url.replace(...);
                data.url = url;
                data.submit();
            }
        });
    }
});

data.submit()向appengine发送POST, appengine返回302(从webapp.RequestHandler返回redirect())。重定向后是否可以从此POST获得响应?

不幸的是,答案是你不能。ajax请求将被透明地重定向,您将从最终页面获得结果。

与其重定向,不如将重定向位置包含在响应数据中,并使用正常的200和所需的数据进行响应。