HTML, calling JS (API)

88 views Asked by At

I have few issues with calling chessboard.js (http://chessboardjs.com). I downloaded API and made new HTML file:

<!DOCTYPE html>
<html>
<head>
  <title>Super chess/title>
  <meta charset="UTF-8"/>
  <script src=":\path-to-js-file\jschessboard-0.3.0.js"></script>
</head>
<body bgcolor="lightgrey">
<div id="board" style="width: 400px"></div>
<script>
var board = new ChessBoard('board', 'start');
</script>
</body>
</html>

I tried to draw chessboard. What I'm doing wrong? Thanks.

2

There are 2 answers

0
user2928585 On

Update:

Tried almost everything, here is my local directory: https://www.dropbox.com/sh/3unwsb8esh9100o/AADHEB8sojQy1PnpLyC8fmSLa?dl=0

I also downloaded jQuery to my local directory, but page still dosen't load. Dev tools in Chrome doesn't import anything. And also tried with xampp (Apache server), because sometimes code doesn't work if you calling it from local directory.

0
jgladch On

From what I can tell based on your code and the docs, you're missing two things:

1) Your title tag isn't closed on line 4 of your html file

2) After you've fixed that problem you'll get an error saying "$ isn't defined" in the chessboard.js file. I teased out that JQuery is a dependency for the chessboard.js file. If you include JQuery in your html (either download the file like you've done with chessboard.js or use a CDN).

You should be good after that!!