jQuery 无法在插件的回调函数中发出任何警报或重定向

jQuery can't alert anything or redirect inside an plugin's callback function

我使用插件上传图片,效果很好,代码是:

$('input[name=photo]').change(function(e) {
    var file = e.target.files[0];

    $.canvasResize(file, {
        width: 600,
        height: 500,
        crop: false,
        quality: 90,
        callback: function(data, width, height) {

            if(width > 100)
            {

            }
            else
            {
                alert("this is not an image"); // this isn't working
                return false;
            }

            var fd = new FormData();
            var f = $.canvasResize('dataURLtoBlob', data);
            f.name = file.name;
            fd.append($('input[name=photo]').attr('name'), f);

            $.ajax({
                url: 'doupload.php',
                type: 'POST',
                data: fd,
                dataType: 'json',
                contentType: false,
                processData: false,
                success: function() {
                    window.location.href = "http://www.whosebug.com"; // THIS ISN'T WORKING TOO
                }
            })
        }
    });
});

完成后,我尝试在 AJAX 完成后重定向到另一个页面,但它不起作用,警报也不起作用。有什么想法吗?

$.ajax({
                url: 'doupload.php',
                type: 'POST',
                data: fd,
                dataType: 'json',
                contentType: false,
                processData: false,
                success: function() {
                    location.href = "http://www.whosebug.com";
                },
                error: function() {
                    //handle errors here
                },
                complete: function() {
                    // this code is always executed
                    location.href = "http://www.whosebug.com";
                }
})

或者

var jqXHR = $.ajax({...
            });
jqXHR.always(function(){
      location.href = "http://www.whosebug.com";
})