getResponseHeader is not a function

不打扰是莪最后的温柔 提交于 2019-12-04 03:04:19

First, your settings object is not well formed, the success function is not terminated.

Edit: Seems that you are using jQuery 1.3.x, if so, the $.ajax function itself returns the XHR object:

$(document).ready(function() { 
    $("[name='submit']").click(function() { 
        var xhr = $.ajax({
            type: "POST",
            data: $(".form-signup").serialize(),
            url: "external.asp", 
            success: function(output, status) { 
              alert(xhr.getResponseHeader("Content-Length"));
            },
            error: function(output) {
              $('.sysMsg').html(output);
            }
        }); 
    }); 
});

For jQuery 1.4+ versions:

Then, when the success callback its executed three arguments are passed (success(data, textStatus, XMLHttpRequest)), you need to call the getResponseHeader on the XmlHttpRequest object, the third argument:

$(document).ready(function() { 
    $("[name='submit']").click(function() { 
        $.ajax({
            type: "POST",
            data: $(".form-signup").serialize(),
            url: "external.asp", 
            success: function(output, status, xhr) { 
              alert(xhr.getResponseHeader("Content-Length"));
            },
            error: function(output) {
              $('.sysMsg').html(output);
            }
        }); 
    }); 
});
Andrew Potts

Is it a cross-domain call? You may be entering a whole new world of pain? (Cross Domain Resource Sharing GET: 'refused to get unsafe header "etag"' from Response) when you do that.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!