【问题标题】:Ajax working on IE and Safari but no working in FF, Chrome and Opera.Ajax 在 IE 和 Safari 上工作,但在 FF、Chrome 和 Opera 上不工作。
【发布时间】:2012-09-21 14:39:55
【问题描述】:

我正在尝试通过 jQuery Ajax 从 html 页面获取 Modal 的数据,它可以在 Safari 甚至 IE 6 中运行,但在 Firefox、Chrome 或 Opera 中无法运行。请指教!

我的代码是here

【问题讨论】:

  • 我通常看到在click函数中首先调用了preventDefault()

标签: jquery html ajax modal-dialog


【解决方案1】:

我在这里看到了一些不寻常的选择器用法:

在您的代码中...

$close = $('<a id="close" href="#">close</a>');

您已将点击事件添加为:

        $close.click(function(e) {
            e.preventDefault();
            method.close();
        });

我真的相信这无论如何都行不通...绑定事件的正确选项将涉及适当的 jQuery 选择器,例如:

        $('#close').click(function(e) {
            e.preventDefault();
            method.close();
        });

或者变量$close应该引用像$close = $('#close');这样的选择器

【讨论】:

  • 感谢 Vishal 的提示,然后我尝试更改代码但它不起作用,模式未打开。有没有通过ajax调用html页面的解决方案。它适用于所有 IE 版本和 Safari,不适用于 FF、Chrome 和 Opera。
  • 哦,结案!当我通过 MAMP 进行测试时,它一切正常:P
猜你喜欢
  • 2018-04-12
  • 1970-01-01
  • 1970-01-01
  • 2013-03-09
  • 2012-03-18
  • 1970-01-01
  • 2010-12-01
  • 1970-01-01
  • 2011-06-01
相关资源
最近更新 更多