The files being requested by jQuery Slimbox are not being retrieved properly

I am currently utilizing jQuery slimbox along with its Application Programming Interface (API).

Below is the JavaScript code snippet that retrieves image paths through JSON and then triggers the slimbox using its API.

$('#main-container').append('<span id="check-our-adverts">Check our Adverts</span>');

    var advertImages = [];
    $.getJSON( config.basePath + 'get-adverts/', function(images) {
       advertImages = images;
    });

    $('#check-our-adverts').click(function() {
        console.log(advertImages);
        $.slimbox(advertImages, 0);    
    });

The JSON data returns

["\/~wwwlime\/assets\/images\/adverts\/advert.jpg","\/~wwwlime\/assets\/images\/adverts\/advert2.jpg"]
.

You can view the actual page here. Click on the top red box next to the frog. Inspect the console for the returned JSON output.

Upon examining the request with Live HTTP Headers, it appears that slimbox is only requesting vanquish.websitewelcome.com/.

This issue leads to the perpetual spinning of the slimbox throbber upon launch.

Any ideas on what could be causing this complication? Thank you

Update

I have included this section within the JSON callback function:

 $.each(images, function(i, image) {
        $('body').append('<a href="' + image + '">link</a>');
       });

Clicking on these links now directly takes me to the respective images... why is this happening?

Answer №1

Although I may not be entirely well-versed in slimbox, according to the API, the method requires an array of arrays as input. Therefore, your JSON output should resemble something like this:

[["\/~wwwlime\/assets\/images\/adverts\/advert.jpg"],["\/~wwwlime\/assets\/images\/adverts\/advert2.jpg"]]

This format is what you would use when calling slimbox:

$.slimbox( [["\/~wwwlime\/assets\/images\/adverts\/advert.jpg"],["\/~wwwlime\/assets\/images\/adverts\/advert2.jpg"]],0);

If this explanation clears things up for you, please let me know!

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

The present IP address of the client through AJAX and PHP

This code snippet is on my PHP page: // Setting the timezone to Asia/Manila date_default_timezone_set('Asia/Manila'); $date = date('m/d/Y h:i:s a', time()); if (!empty($_SERVER['HTTP_CLIENT_IP'])){ $ip=$_SERVER['HTTP_C ...

What is the best way to display data on a Progress bar using PHP?

Our team is currently developing a ProgressBar with Jquery UI but we are encountering issues. Specifically, we are unable to retrieve values from PHP and create a numerical loop that can pass the value back to Ajax-based code. Here is a snippet of our cod ...

Tips on effectively extracting data from a SQLite JSON field that contains an array value

Within my sqlite database, there is a field that contains a complete JSON object. I need to perform some select queries on this JSON data. Specifically, I am looking to extract comments where the "pod" field is 'fb'. How can I properly extract th ...

Using Jquery to create a simple filter system that allows checkboxes to remain checked

I am currently working on a basic filter system where I need HTML checkboxes to display and hide items based on specific categories. However, the issue I am facing is that the checkboxes remain checked regardless of the selection. For example, you can se ...

Is it possible to use a delegate to trigger events in a predetermined sequence?

My goal is to trigger an alert when a link is clicked. Is it feasible to specify which alert is triggered first? $("#container").delegate("a.link", "click", function(){ alert("This was message #1"); }); $("#container").delegate( ...

When working with an array of objects in Vue.js, what is the optimal approach: replacing the entire array or modifying individual values?

I am currently utilizing Vue and Vuex to dynamically generate components from an array retrieved from SQLite using the library better-sqlite3. let table=[ { id:1, column_1:'data', column_2:'data', column_3:{'1&apo ...

Dealing with an endless loop caused by a promise in AngularJS's ui router $stateChangeStart event

I am currently working on implementing authentication in my Angular application and I want to redirect to an external URL when a user is not logged in (based on a $http.get request). However, I seem to be stuck in an infinite loop when using event.prevent ...

jQuery Algorithm for calculating totals

Here is an algorithm for formatting amounts using jQuery: Visit jsfiddle for the code However, there are some issues. For instance, if I enter 900.800,00 and then delete the "9", it still displays 00.800,00. How can this be resolved? I have fixed severa ...

Ways to retrieve the data received from an axios.post request in the server-side code

Currently, I am working on a project that involves using React for the frontend and Spring Boot for the backend. However, I am facing an issue with retrieving data that I have sent using Axios from the frontend to the backend. The code snippet below show ...

Async await function two is failing to execute

I am currently working on a process where I need to unzip a file first, wait for the unzipping process to complete, and then loop through each extracted file to upload it to an S3 bucket. The unzipPromise function is working as expected, successfully unz ...

The autocomplete functionality with ajax is currently malfunctioning

<script> function autocomplet1() { var min_length = 0; // minimum characters to display the autocomplete var keyword = $('#select01').val(); if (keyword.length >= min_length) { $.ajax({ url: 'barcode ...

transferring attributes from a component iterated over to a component it renders

Admitting my lack of expertise, I am seeking assistance with the implementation of the following code. This is my "posts" component responsible for making an API call to fetch all post data: import React from 'react' import Post from '../pos ...

How can we use AJAX in Ruby on Rails to update the cart when the quantity of items is changed, ensuring that the cart is saved in the session

UPDATE: I have successfully found a solution to my problems. Thank you for all your support! Currently, I am working on creating a simple shopping cart with ajax using Ruby on Rails. I am looking to implement an ajax feature on my cart page that updates ...

HTML: Determine the Precise Location of a Div Element That is Centered

Imagine I have this image: Is there a way for me to determine the x/y or left/top properties of my canvas if it is centered using the following CSS: #canvas-container { width: 100px; height:100px; margin: 0px auto; } Note ...

Determine the hour difference between two provided dates by utilizing the date-fns library

My API returns a "datePublished" timestamp like this: "2019-11-14T14:54:00.0000000Z". I am attempting to calculate the difference in hours between this timestamp and the current time using date.now() or new Date(). I am utilizing the date-fns v2 library fo ...

Transforming a pandas Dataframe into a collection of dictionaries

Within my Dataframe, I have compiled medical records that are structured in this manner: https://i.stack.imgur.com/O2ygW.png The objective is to transform this data into a list of dictionaries resembling the following format: {"parameters" : [{ ...

Improving the Speed of Ajax Auto Complete

We have implemented an ajax auto complete script in MySQL which functions as follows: <?php $q = strtolower($_GET['term']); if (!$q) return; $q = noescape($q); if (is_numeric($q)){ $q = mysql_query("SELECT * FROM `blah` WHERE `id` LIKE & ...

Transmit the bound data (using ng-model) to a custom AngularJS directive

/*I am looking to define the maxDate as vmEndDate*/ app.directive('myDatepicker', function ($parse) { return function (scope, element, attrs, controller) { var ngModel = $parse(attrs.ngModel); alert(element.va ...

Is there a way to use jQuery to make a div fade in and toggle over another

I have created a test page and I am looking to achieve a specific effect when the page loads. I want everything on the page to be hidden initially. When I click on the "About" text, I want it to fade in using fadeToggle(); however, when I click on "My work ...

SCRIPT438: The operation failed because the object does not have the ability to use the 'forEach' property or method

Issue with IE8: Property or method 'forEach' not supported $('.tabs').tabs(); $('#search-consumables [data-ajax-call]').change(function() { var $this = $(this), settings = $this.data(), $target = $(setti ...