Skip to content

Author: admin@master

Fetch: POST JSON data

I’m trying to POST a JSON object using fetch. From what I can understand, I need to attach a stringified object to the body of the request, e.g.: When using jsfiddle’s JSON echo I’d expect to see the object I’ve sent ({a: 1, b: 2}) back, but this does not happen – chrome devtools…

Slick carousel right to left

I’ve setup slick carousel to continuously scroll, however I need to to scroll in the oposite direction. Adding the RTL option didn’t seem to work. Fiddle here (currently left to right) http://jsfiddle.net/mth2ghod/ Answer Change the slidesToScroll to a -1 (it will change the slide direction)

How can I run a jQuery function only when it’s needed?

I’ve run into a problem where I have a responsive slider running on my site which has been added to an external .js file. I am running into an issue with a modal not popping up on the homepage because the page is looking for the slider which is only included on a couple of sub pages. Chrome console is

generate 4 digit random number using substring

I am trying to execute below code: I am getting error like undefined is not a function at line 2, but when I try to do alert(a), it has something. What is wrong here? Answer That’s because a is a number, not a string. What you probably want to do is something like this: Math.random() will generate a flo…

Cordova SQLite save BLOB

I have a problem with Cordova SQLite plugin. How can I save BLOB image to SQLite? I have BLOB object in JS: And I trying to save it And when i trying to get this image: I get this string: How can i convert it to BLOB again? Also i trying to save images in base64, but i can’t save

How to get total number of hours between two dates in javascript?

I am in a situation where I need to find out the total hour difference between two date objects but the thing is dates aren’t present in the actual format. Date 1: 6 Apr, 2015 14:45 Date 2: 7 May, 2015 02:45 If it would have been in standard format, simply I would have been used below method: var hours