The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
initialize jquery with some js which require jquery
#1
i have added jquery in my header.php file under /usersc/includes
Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

under this line i added a js library which depends on jquery loaded before.
Code:
<script type="text/javascript" src="/usersc/js/myUIlib.min.js"></script>

the error console says "$ is not defined"

since there are 3 reasons this error could have:
  • 1. Your JavaScript file is not being properly loaded into your page
  • 2. You have a botched version of jQuery. This could happen because someone edited the core file, or a plugin may have overwritten the $ variable.
  • 3. You have JavaScript running before the page is fully loaded, and as such, before jQuery is fully loaded.


so i assume:

1. it is properly loaded as i can see in network analysis in firefox debug view
2. are there some plugins which override the $ variable?
3. i think my UIlib.min.js is loaded after jquery, i see it in network analysis so jquery should be finished before my UIlib.min.js is fired. or is there any other place to put those script?


i also see jquery is loaded twice? where is it loaded it should only loaded once in the header of the page(/usersc/includes/header.php) i think.

EDIT:

if i reference it in a blank content page both jquery and my myUIlib.js there are the same errors from the header, but on the page it is working. so what is wrong with the header ? is it loaded after the page content?
  Reply
#2
when i put the two lines in the /user/includes/header.php

it is working without error. no clue why.. but it works.
  Reply
#3
Can you paste your header.php to pastebin or hastebin and share the link so I can see what's going on?

I'm not a javascript guy (I'm learning), so there's a good chance I goofed something with jQ.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)