0

i'm nearly embarrassed to ask this kinda basic question, but i can't find the error... I try to provide code from external libraries locally, but it won't work. The code works perfectly when loaded from an URL or injected directly into the HTML file, but it doesn't recognize the javascript file.

Tried to move the files since i thought i just had typos, but even webstorm says it's correct. Also provided correct type to the file.

In this scenario the HTML file and the local .js files are in the same folder. External file i try to embed locally: here

<!DOCTYPE html>
<html>
<head>
    <title>Test file</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="survey.jquery.js"></script>
</head>
<body>

</body>
</html>

This simple code results everytime in the error SyntaxError: expected expression, got '<' in the Firefox console.

Also the Survey object from the file isn't recognized/loaded. Looking up the error results in missed out brackets, but the code should be correct.

Lukas S
  • 315
  • 1
  • 3
  • 15
  • No error in your sample code. Press CTRL+SHIFT+J in the browser. This should open the browser console and the line with the formating error will highlighted. Click the line number on the right and you should be taken to the error. – Tigger Sep 06 '19 at 22:19
  • Ah thank you... It leads me to this error "Could not get the list of font families Protocol error (unknownError): node is null" from the text-property-editor.js:545:19 (resource is devtools itself). Never had that kind of error while doing web developing ... Do you know where it comes from? – Lukas S Sep 06 '19 at 22:33
  • Ignore that error (as you said it is in the devtools) and look for an error in your code or an imported or referenced script. – Tigger Sep 06 '19 at 22:45
  • Suddenly it works now without changing anything. But what i don't get is why i bitches around so easily. I edited 1 line, got an error, changed the line back to original and now it won't load. It tells me on all Scripts "SyntaxError: illegal character", while on line 1 there is just a comment "/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */" – Lukas S Sep 07 '19 at 16:13
  • You can open a sample on the surveyjs.io site. E.g. https://surveyjs.io/Examples/Library/?id=questiontype-text&platform=jQuery&theme=default and press the "Edit in Plunker" button. Thus you will have a live working sample. E.g. https://plnkr.co/edit/AZWrPgBOS74wVcBPjrbr?p=preview – TSV Sep 09 '19 at 08:05
  • @TSV the problem is i got anything related with surveyjs working. The problem is that i can't include local javascript files. The problems also seems the same with images. Have tried different paths and also checked if i'm in the correct path, but it's not recognized from within javascript. The images can be included via img src, but somehow i can't get the images with the same location in javascript. There seems to be a wall or something... – Lukas S Sep 09 '19 at 18:26
  • I might have an idea for the problem ... Firefox is showing me now this error message: The resource from “http://localhost:63342/node_modules/emotion-ratings/dist/emotion-ratings.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). Even though i set the type to "application/javascript" or "text/javascript" it still appears. What can i do to accept the right content type? – Lukas S Sep 09 '19 at 18:50

0 Answers0