2

当使用 jQuery 进行 AJAX 调用时,我暂时只想有一个弹出框(使用alert())向我显示响应文本。

$(document).ready(function() {
    $(".jeobutton").mouseup(function() {
        var $button = $(this);
        $.ajax({ url: 'getdata.php',
            data: // <parameters>
            type: 'get',
            dataType: 'json',
            success: function(output) {
                // do something
            },
            error: function(xhr) {
                alert("<some error>");
                console.error(xhr.responseText);
            }
        });
    });
});

响应文本打印得很好。但是,alert()找不到对话框。

请帮助这个可怜的菜鸟。

4

2 回答 2

4

这是一个与您的代码非常接近的jsfiddle,正在工作,弹出警报框。

http://jsfiddle.net/pN869/

$(document).ready(function() {
    $(".jeobutton").mouseup(function() {
        console.log("clicked");
        var $button = $(this);
        $.ajax({ url: 'getdata.php',
            type: 'get',
            dataType: 'json',
            success: function(output) {
                console.log("success");
            },
            error: function(xhr) {
                alert("<some error>");
                console.error(xhr.responseText);
            }
        });
    });
});
于 2013-09-29T02:00:51.000 回答
-1

清理浏览器缓存。可能会有不显示更多警报的选项。在不同的浏览器中测试。

我希望这会有所帮助。

于 2015-06-26T23:14:05.183 回答