Hello!

The site has a "Save" button, when clicked, nothing happens. Google console gives the error: Uncaught TypeError: $ .jGrowl is not a function

I mean plugged in .js

<script src="/application/public/widgets/jgrowl-notifications/jgrowl.js"></script> 

There is no error, the $ .jGrowl function displays the text as expected, but jgrowl.css is not used, because it is not connected, so it probably does not apply.

I connect it like this:

 <link rel="stylesheet" type="text/css" href="/application/public/widgets/jgrowl-notifications/jgrowl.css"> 

Then there is no error, but the text disappeared altogether, that is, it is not displayed in any form.

Please tell me what the problem is.

All code:

 <?php defined("NET2FTP") or die("Direct access to this location is not allowed."); ?> <style> .btn { display: inline-block; margin-bottom: 0; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer; background-image: none; border: 1px solid transparent; white-space: nowrap; padding: 6px 12px; font-size: 14px; line-height: 1.428571429; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; } .btn-primary, .btn-primary:focus, .btn-hover-primary:hover, .btn-hover-primary:active, .btn-hover-primary.active, .btn.btn-active-primary:active, .btn.btn-active-primary.active, .dropdown.open>.btn.btn-active-primary, .btn-group.open .dropdown-toggle.btn.btn-active-primary { background-color: #579ddb; border-color: #5fa2dd; color: #fff; } </style> <link href="/application/public/widgets/jgrowl-notifications/jgrowl.css" rel="stylesheet" type="text/css"> <script src='/application/public/widgets/jgrowl-notifications/jgrowl.js' type='text/javascript'></script> <!-- Template /skins/shinra/edit.template.php begin --> <form id="<?php echo $formname; ?>" action="" method="post"> <?php printLoginInfo(); ?> <input type="hidden" name="state" value="edit" /> <input type="hidden" name="state2" value="" /> <input type="hidden" name="directory" value="<?php echo $net2ftp_globals["directory_html"]; ?>" /> <input type="hidden" name="screen" value="2" /> <input type="hidden" name="textareaType" value="<?php echo $textareaType; ?>" /> <table style="padding: 2px; width: 97%; height: 100%; border: 0px;"> <tr> <td colspan="3" style="vertical-align: top; text-align: <?php echo __("left"); ?>;"> <div style="margin-<?php echo __("left"); ?>: 0px; text-align: <?php echo __("left"); ?>;"> <?php /* ----- Plain textarea ----- */ ?> <?php if ($textareaType == "" || $textareaType == "plain") { ?> <?php // Do not use style="white-space: nowrap;" because then IE strips the carriage-return + linefeeds (tested on IE version 6.0) ?> <textarea name="text" class="edit" rows="33" style="color: #FFF; background-color: #121921; font-family: Inconsolata;width: 100%; height: 400px;margin-bottom: 10px;" wrap="off" onkeydown="TabText()"><?php echo $text ?></textarea> <?php } /* ----- CKEditor or TinyMCE ----- */ elseif ($textareaType == "ckeditor" || $textareaType == "tinymce") { ?> <div id="header_hidden"></div> <div id="header_shown" style="display: none;"><textarea name="text_splitted[top]" style="width: 100%; height: 200px;"><?php echo $text_splitted["top"]; ?></textarea></div> <div id="body_hidden"></div> <div id="body_shown" style="display: block;"><textarea cols="120" rows="35" id="text_splitted[middle]" name="text_splitted[middle]"><?php echo $text_splitted["middle"]; ?></textarea></div> <div id="footer_hidden"></div> <div id="footer_shown" style="display: none;"><textarea name="text_splitted[bottom]" style="width: 100%; height: 200px;"><?php echo $text_splitted["bottom"]; ?></textarea></div> <?php } /* ----- Ace ----- */ elseif ($textareaType == "ace") { ?> <input type="hidden" name="text" value="" /> <div id="editor" name="text"><?php echo $text; ?></div> <script type="text/javascript"> var editor = ace.edit("editor"); editor.setTheme("ace/theme/<?php echo $ace_theme; ?>"); editor.getSession().setMode("ace/mode/<?php echo $ace_mode; ?>"); </script> <?php } ?> </div> </td> </tr> <tr color="#c3c3c3"> <td style="vertical-align: top; text-align: <?php echo __("left"); ?>; width: 25%;"> <button onClick="document.forms['<?=$formname?>'].screen.value=3; " class="btn btn-primary">Сохранить</button> </td> </tr> </table> </form> <script type="text/javascript"> $(function(){ $('#<?=$formname?>').submit(function(e){ //отменяем стандартное действие при отправке формы e.preventDefault(); //берем из формы метод передачи данных var m_method=$(this).attr('method'); //получаем адрес скрипта на сервере, куда нужно отправить форму var m_action=$(this).attr('action'); //получаем данные, введенные пользователем в формате input1=value1&input2=value2...,то есть в стандартном формате передачи данных формы var m_data=$(this).serialize(); $.ajax({ type: m_method, url: m_action, data: m_data, success: function(result){ $('#status').html(result); $.jGrowl("Конфиг успешно сохранен!", { sticky: !1, position: "top-right", theme: "bg-green" }); //$.jGrowl(data.success, { sticky: !1, position: "top-right", theme: "bg-green" }); //toastr.success('</b> Конфиг успешно сохранен!'); } }); }); }); </script> <!-- Template /skins/shinra/edit.template.php end --> 

Closed due to the fact that off-topic participants VenZell , aleksandr barakin , user207618, Ivan Pshenitsyn , rdorn Aug 17 '16 at 22:10 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - VenZell, aleksandr barakin, Community Spirit, Ivan Pshenitsyn, rdorn
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Collect a minimal reproducible example of the problem right in the question. - VenZell
  • @VenZell, laid out all the code. - Max
  • What you need is not “all code”, but a minimal self-sufficient example to reproduce your problem. The problem is reproduced on such a layout: here is a piece of your layout . Why should the respondents know how you build php with the help of php? Why not the resulting posted? Again, I emphasize the need for a minimal example. - VenZell
  • @VenZell, sorry, but I do not understand you. What does the minimal example mean? - Max
  • Here's a link to the help: the minimum reproducible example is VenZell

1 answer 1

jQuery forgot to connect. You can get from here on CDN .

It should look like this:

 <head> <link href="http://ksylvest.imtqy.com/jquery-growl/stylesheets/jquery.growl.css" rel="stylesheet" type="text/css"> </head> <body> <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script src='http://ksylvest.imtqy.com/jquery-growl/javascripts/jquery.growl.js' type='text/javascript'></script> <script type="text/javascript"> $(function() { $.growl({ title: "Growl", message: "errits already released in SU or Submitted for SU!" }); }); </script> </body> 

Detailed initialization is here .

  • I saw this code. It does not work for some reason. - Max
  • @Maxim In the console, look at the errors, most likely because of this. - user192664
  • the fact of the matter is that there is no error. If you remove growl.css, the text is written, but not as it should be, but as soon as I connect growl.css - everything, nothing happens. - Max