ajax and codespace issue - ajax

I am using codespace with VS code
This is how the folder looks like
I am trying to use Ajax to display some text into div which is imported from HTML page"cap.html" which was created under the templates folder
if I move the cap.html file to the same folder it works
ajax.open('GET', '/static/cap.html',true);
" GET /static/cap.html HTTP/1.1" 200 -"
if it stays in the templates folder
ajax.open('GET', '/templates/cap.html',true);
I get "GET /templates/cap.html HTTP/1.1" 404 "
how should i keep the html page in the templates folder and make it also work !?

Related

Website showing 404 instead of automatically showing index.html

I use OpenLiteSpeed as a web server, and when I load my website I get a 404 error instead of it automatically loading the index.html page, when I put index.html in manually the page loads without a problem

i don't see any images on my site

In localhost (Xampp) I created a website folder, there are index.html, css, php and a folder with images. I wrote a link to the image I want to be in the index.html
< body >
< img src="website/images/image.jpg"
but when I open this site in browser, there are no any images on my page. What's the problem?
I guess the correct path would be
images/image.jpg
Because your file is already inside the website folder.

Including jquery in .js file

I am trying to clone an object using
var newObject = jQuery.extend(true, {}, oldObject);
as per John Resig's answer to What is the most efficient way to deep clone an object in JavaScript? .
All the information I can find on using libraries in javascript only show how to use a library within an html file... as in:
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
My code is in a .js file and i get the error that jQuery is not defined. How do I use jQuery within my .js file?
EDIT: I'm running this code in a server.js file on a node server. The server.js has an event handler that gives back the index.html file upon getting the "/" url. So the server.js file isn't included in the index.html file and therefore including jquery in the html file doesn't help me, if my understanding is correct.
You can't include it or link to it from within your .js file. You have to include it on the HTML page (<script src="/path/to/jquery"></script>), before you include your .js file.
Technically you could just copy and paste the jquery code above the code in your .js file, but it is usually a better idea to just include it on the page to avoid conflicts.

Duplicated /blog link at pagination section

I new to octopress and I passed thought an issue with main page links.
All links was duplicated like /blog/blog and I fixed this at source files.
Now, everything is fine but "Blog Archives" link (/blog/blog/archives) at div with class "pagination", at index.html, close to footer section.
I looked into source files and it appears fine but if I run "rake generate", after change the wrong url at index.html, it backs to /blog/blog/archives.
Which file I need to change to fix that issue?
The header "Blog Archives" is fine.
I solved changing permalink: /blog/:year/:month/:day/:title/ for permalink: /:year/:month/:day/:title/ in _config.yml, like hsigrist said in the comment.

Favicon issue in website

I am using a favicon which is linked in all pages using <link> tag. This favicon is stored in a folder inside the root folder, and I have another favicon stored in the root folder also. When the site loads fully the favicon which I am referring to is shown correctly. But when I stop the site before loading completely then it shows the favicon from the root folder.
Is this the default/desired behavior?
Thanks
I'd say yes.
The only way the browser can find your correct favicon is by using the <link> tag. If that tag's not present or parsed correctly the browser will have to fall back on its default behaviour which is to look for a file called favicon.ico in the root folder.
I don't know about desired behaviour, but it is to be expected. The browser will request /favicon.ico by default, and the <link> is considered an override.
You will find for most browsers, they will actually fetch both, but display the <link> by preference.
Most browsers, if they don't find a <link rel="icon"> or <link rel="shortcut icon">, fall back on the old bog-standard of showing /favicon.ico . Some can be configured to avoid this (e.g. Opera has this in GUI config), some will look for /favicon.ico regardless.
This is an artifact of the Browser Dark Ages and no fault of your own.

Resources