简体   繁体   English

jQuery在Firefox和IE中不起作用

[英]jQuery not working in Firefox and IE

I have a PHP verification like this: 我有这样的PHP验证:

if (empty($_POST['name'])) {


        $userMessage = '<script type="text/javascript"> 


        Nname() ;


        </script>';
        }

Function above corresponds with jQuery: 上面的函数与jQuery相对应:

   function Nname () {

        $('#Nname').slideToggle(500).delay(3000).slideToggle(500);

    }

Which reveals a div containing the notification: 其中显示了一个包含通知的div:

<div class="warning" id="Nname">

    <div id="warn_name"> Please enter your first name. </div>

</div> 

I have a series of notifications set up like this and everything works great in Chrome, Opera and Safari. 我有一系列这样的通知设置,并且一切在Chrome,Opera和Safari中都可以正常运行。 However, Firefox and IE show nothing at all. 但是,Firefox和IE完全不显示任何内容。

Upon clicking the button which triggers the notifications, in Firefox and IE page simply reloads and shows nothing. 单击触发通知的按钮后,在Firefox和IE页面中,仅重新加载并什么也不显示。

How can I fix this? 我怎样才能解决这个问题?

SOLVED!: 解决了!:

I posted the solution below! 我在下面发布了解决方案!

In your PHP try this, I am thinking the function isn't getting called. 在您的PHP中试试这个,我认为函数没有被调用。

if (empty($_POST['name'])) {
  $userMessage = 
  '<script type="text/javascript"> 
   $(document).ready(function(){
        console.log(\'here\');
        Nname() ;
   });
  </script>';
}

or try this, without document ready (just see if it sends a console log); 或尝试此操作,而无需准备好文档 (只需查看它是否发送了控制台日志)即可;

if (empty($_POST['name'])) {
      $userMessage = 
      '<script type="text/javascript"> 
            console.log(\'here\');
            Nname() ;
      </script>';
    }

It seems that the problem wasn't with either jQuery or PHP. 看来问题不在于jQuery或PHP。 What was causing the issues was the submit button. 引起问题的是提交按钮。 I have a rollover image as a submit button and it doesn't execute the PHP script upon clicking in Firefox and Internet Explorer. 我有一个过渡图像作为“提交”按钮,在Firefox和Internet Explorer中单击后,它不执行PHP脚本。

Rollover image was created using jQuery and some modifications solved the issue. 滚动图像是使用jQuery创建的,并且进行了一些修改解决了该问题。

Detailed explanation: Submit rollover button not working in FF and IE 详细说明: 提交翻转按钮在FF和IE中不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM