Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ajax不适用于opera_Javascript_Jquery_Ajax_Opera - Fatal编程技术网

Javascript ajax不适用于opera

Javascript ajax不适用于opera,javascript,jquery,ajax,opera,Javascript,Jquery,Ajax,Opera,我的ajax代码在opera中不起作用,但是,它适用于所有其他主要浏览器: $(function() { $("a").on('click', function(e) { var href = $(this).attr('href'); $.ajaxSetup({ beforeSend:function(xhr) { $('div.imagePlace').animate({height: '10px'}); }, }); $.aja

我的ajax代码在opera中不起作用,但是,它适用于所有其他主要浏览器:

$(function() {  
$("a").on('click', function(e) {
    var href = $(this).attr('href');
    $.ajaxSetup({
        beforeSend:function(xhr) { $('div.imagePlace').animate({height:      '10px'}); },
    });
    $.ajax();
    e.preventDefault();

    setTimeout(function() {
    $.ajax({
        url: href,
        dataType: "html",
        success:function(result) {
            $('.imagePlace').html(result)
            $('.imagePlace').animate({height: '500px'})
        }
    });
        }, 400);
});


    });

有人能看出歌剧中的问题是什么吗?提前谢谢

Opera内置了一个名为Dragonfly的调试工具。进入工具菜单->高级->歌剧蜻蜓 如果没有文件菜单栏,请单击菜单->页面->开发人员工具->打开Opera Dragonfly

打开后(在您正在处理的页面上打开),单击脚本选项卡(它可能会要求您刷新页面并执行该操作),然后下拉到外部js文件。找到代码后,可以通过单击左侧的行号在
$.ajax()
行上设置断点。现在,触发您的代码,您将看到它将在JavaScript行上中断。然后可以使用“检查”选项卡(底部、中间)确保所有变量都设置正确。您还可以单步执行并调试JavaScript

您要做的另一件事是添加一个错误函数,如下所示:

$(function() {  
$("a").on('click', function(e) {
    var href = $(this).attr('href');
    $.ajaxSetup({
        beforeSend:function(xhr) { $('div.imagePlace').animate({height:      '10px'}); },
    });
    e.preventDefault();
    setTimeout(function() {
    $.ajax({
        url: href,
        dataType: "html",
        success:function(result) {
            $('.imagePlace').html(result)
            $('.imagePlace').animate({height: '500px'})
        }
        error: function(xhr, textStatus, errorThrown) {
        alert(errorThrown);
        }
    });
        }, 400);
});

});

看看这是否提供了更多信息。

唯一的
$.ajax()是什么应该做什么以及什么“不起作用”?请求是否未发送?是否未执行回调?你必须给我们的不仅仅是“它不工作”,还有一个滑动面板。当单击按钮ajax request send时,滑动面板下降。此滑动面板的类别为imagePlace。但是这个滑动面板不工作,所以我认为请求没有发送!