Server blocking access to Javascript files

Having some trouble with my code, it works fine on Localhost but not on Fasthosts server. Seems to be an access issue to a folder on the server, here are the debug messages:

GET (http://reggarockaboogie.co.uk/images/gallery/fld01/) 403 (Forbidden)

k.cors.a.crossDomain.send @ jquery.min.js:4
n.extend.ajax             @ jquery.min.js:4
LoadGallery               @ gallery.html:95
(anonymous function)      @ gallery.html:86
j                         @ jquery.min.js:2
k.fireWith                @ jquery.min.js:2 
n.extend.ready            @ jquery.min.js:2
I                         @ jquery.min.js:2

Check out my code below:

     < script >
      $(document).ready(function() {
        LoadGallery($('a[data-albumid]:first').data('albumid'));
        $("a").click(function() {
          var dir_path = $(this).data("albumid");
          LoadGallery(dir_path);
          return false;
        });
      });

    function LoadGallery(dir_path) {
      $.ajax({
        url: dir_path,
        success: function(data) {

          $(".image-container").empty();

          $(data).find("a:contains(.jpg), a:contains(.png), a:contains(.jpeg)").each(function() {
            this.href.replace(window.location.host, "").replace("http:///", "");
            var file = dir_path + $(this).text();
            $(".image-container").append($("<a href='javascript:;' class='thumb' data-src='" + file + "'><img src='" + file + "' title='Click to        enlarge' alt='#'/></a>"));

            if ($(".image-container").children("a").length === 30) {
              return false;
            }
          });

          $(".image-container").append("<strong><p>Click on a thumb nail to show a larger image.</p></strong>");

          $(".thumb").bind('click', function() {
            var Popup = "<div class='bg'></div>" + "<div class='wrapper'><img src='<img src=''/>" + "<label href='javascript:;' class='prev-image'>«</label><label href='javascript:;' class='next-image'>»</label><a href='javascript:;' class='close' title='Close'>Close</a>";
            var Img = $(this).attr("data-src");
            $("body").prepend(Popup);
            $(".bg").height($(window).height() * 4);
            $(".wrapper img").attr("src", Img);

            $(".prev-image").bind('click', function() {
              var prev = $(".image-container").find("img[src='" + Img + "']").parent().prev('a').find("img").attr('src');
              if (!prev || prev.length === 0)
                return false;
              else {
                $(".wrapper img").attr("src", prev);
                Img = prev;
              }
            });

            $(".next-image").bind('click', function() {
              var next = $(".image-container").find("img[src='" + Img + "']").parent().next('a').find("img").attr('src');
              if (!next || next.length === 0)
                return false;
              else {
                $(".wrapper img").attr("src", next);
                Img = next;
              }
            });

            $(".close").bind('click', function() {
              $(this).siblings("img").attr("src", "")
                .closest(".wrapper").remove();
              $(".bg").remove();
            });
          });
        }
      });
    }; < /script>
@import url(http://fonts.googleapis.com/css?family=Varela+Round);

#nav {
    float: left;
    width: 20px;
    margin: 10px 10px 20px 0px;
}
#nav, #nav ul {
    list-style: none;
    padding: 0;
}
#nav a {
    position: relative;
    display: block;
    width: 105px;
    padding-left: 10px;
    margin: 3px 0;
    text-decoration: none;
    font-family: Geneva, Arial, Helvetica, sans-serif;
    font-variant: small-caps;
    font-weight: bold;
    color: #fff;
}
#nav a:link, #nav a:visited {
    border-left: #00425E solid 10px;
    color: #fff;
}
#nav a:hover, #nav a:active {
    border-left-color: #fff;
    background-color: #770709;
    color: #fff;
}
#nav a#here {
    border-left-color: #fff;
    background-color: transparent;
    color: #fff;
}
#nav ul {
    margin-left: 20px;
}

<!-- remaining CSS and HTML codes for the page omitted -->

Answer №1

When attempting to access the URL, a 403 error is returned, which indicates that the issue lies within the server configuration and not with your client-side code.

Possible causes for this error include:

  • Directory listings being disabled (requiring a change in server settings, such as enabling the indexes option in Apache).
  • File permissions set on the server's directory preventing the web server software from reading it (often adjusted using chmod).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Facing issues while attempting to retrieve the generated PDF through an Ajax-triggered controller action

I am having trouble downloading a PDF/XLSX file from the controller. I have tried using both jQuery and Ajax, but I can't seem to get it to work. Here is an example of the code in the controller: var filestream = new FileStream(pdfoutputpath + " ...

What is the best way to clear the selected option in a dropdown menu when choosing a new field element?

html <div class="row-fluid together"> <div class="span3"> <p> <label for="typeofmailerradio1" class="radio"><input type="radio" id="typeofmailerradio1" name="typeofmailerradio" value="Postcards" />Postcards& ...

Ways to align two buttons side by side in HTML

I'm struggling with the code on my company's website. I can't seem to get the buttons to float properly with the given code. <div class="text-center"><a class="text-center" href="/contact-us"><button class="btn btn-small btn- ...

What could be causing the JQuery Post and Get methods to not respond or execute when they are invoked?

I'm currently working on a project where I need a webpage to automatically open other pages using the post method through a script, without requiring direct user input. I've tried using the JQuery post method, but haven't had any success so ...

jquery method for clearing input field values

I am facing an issue with the form where the company name field automatically loads a value, even though it is a required field. I simply want to clear the previous loaded value and allow the user to input their information. For example, if I previously e ...

Changing the size of various types of images

Is there a way in JavaScript to automatically resize and fill in a block with fixed width using different images with various dimensions? I came across something similar, but it was in AS2. I'm unsure if it can be translated to JavaScript. var _loc3 ...

Is it possible to maintain tab focus instead of visual focus when navigating past the skip navigation menu for improved accessibility?

My website features an accessibility skip navigation menu that utilizes named anchors to navigate to different content areas. These content areas, including the top menu, left menu, main body content, and footer menus, contain links within them. When I u ...

An error occurred while trying to convert a circular data structure to JSON during an API request within another

Attempting to make an API call within another API call in this code, however encountering the following error: Error: Converting circular structure to JSON const express = require('express'); const router = express.Router(); const config = requi ...

modify the final attribute's value

Hello I've been using skrollr js to create a parallax website. However, the issue arises when determining the section height, as it depends on the content within. My goal is to locate the last attribute and adjust the number value based on the section ...

Issues with routeparams are preventing ng-repeat from functioning properly, without any response or resolution

For my shoppingCart project, I am working on dynamically bringing data into views. I am using routeParams in template.html but facing an issue. The data is arriving normally as checked via ng-href="#/store/{{something.name}}/{{ child.name }}" but it isn&ap ...

What methods can I use to eliminate an iframe virus that has infected all my PHP files on my website?

I'm facing a challenge with eliminating a virus code from my php files. All 1200+ php files on my server have been infected by this malicious code, which injects the following line into the html output: Here is the virus code: <tag5479347351>& ...

What is the best way to delete a particular CSS class using jquery?

My task is to remove the "btn" class from items that have an additional argument in their class name, such as: <input type="button" class="btn btn-mini btn-success email-user" id="emailid5" value="Email Tester"> I specifically need to only remove t ...

Is the JavaScript Base64 image data damaged or compromised?

My current task involves selecting an image through an HTML Input and then retrieving the image using Javascript to obtain its Base64/Image Data string. However, the code I have implemented is only returning a partially corrupt or invalid representation o ...

Exporting Python Pandas Data Frame to an HTML file

I'm attempting to save a Python Pandas Data Frame as an HTML page. I also want to ensure that the table can be filtered by the value of any column when saved as an HTML table. Do you have any suggestions on how to accomplish this? Ultimately, I want t ...

Utilize jQuery autocomplete to limit user input in a text box

I'm currently implementing jQuery UI's autocomplete feature to populate a form input with accurate data from a list of over 1000 values. The autocomplete functionality is functioning correctly, but I am unsure how to restrict the field's va ...

Issue encountered in Vuejs when attempting to remove a component using directives while the mounted or created event is still being executed

I created a custom directive that functions like v-if. In the directive, I check access rights and remove the element if access is not granted. Below is my code: Vue.directive('access', { inserted: function(el, binding, vnode){ // ...

When the button is clicked, send data using 'POST' method to the php file and fetch

<script> $(document).ready(function(){ $("#vE_rebtn").click(function{ var reverifyEmail = '<?php echo $_SESSION["verifyEmIPv"]; ?>'; $('#rE_rebtn').hide(); $('#re_ ...

Node.js is essential when using Angular for implementing ui-select components

I'm currently delving into learning AngularJS. I've successfully created a basic web application using AngularJS, with Java EE powering the backend (server side). This app is being hosted on Tomcat. The advantages of AngularJS over JQuery are bec ...

Enhance Your Data Visualization with jqplot Bar Chart Hover Feature

I am looking to add a tooltip div directly above the value of my bar chart. For example, if the bar values are around 90 and 80, on mouse-over the [value box] should appear right above the value of the current bar in the chart. Is there a way to position ...

Ways to simulate a variable imported in the module being tested without it being a function parameter can be achieved by using describe.each and changing the mock value for each test

I have a requirement to test a function within my TypeScript module. module-to-test.ts import { config } from './app-config'; export const isSomethingWhatINeedSelector = createSelector( firstDependencySelector, secondDependencySelector ...