简体   繁体   中英

Why doesn't my javaScript work when I echo it out in php?

I have a test file and when I run this script all I see is a blank page. I'm supposed to see a red banner that slides down from the top and says "there was an error". I've already tried echoing each line. I still have the same problem. What am I doing wrong?

<?php
echo '<script language="javascript">
   $(document).ready(function(){

   $(this).notifyMe(
      "top", 
      "error",
      "", // Title
      "there was an error", 
      300; 
      3000; 
   );

 });
 </script>';

?>

Remove ; inside notifyMe()

$(this).notifyMe(
  "top", 
  "error",
  "", // Title
  "there was an error", 
  300,
  3000 );
<?php
echo '<script language="javascript">
   $(document).ready(function(){

   $(this).notifyMe(
  "top", 
  "error",
  "", // Title
  "there was an error", 
  300, 
  3000
   );

 });
 </script>';

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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