Killersites Forum » Javascript
961 FOLLOWERS
KillerSites has been teaching web designers and developers practical, marketable skills. Get developer training and tutorials, find the quickest and easiest way to learn Javascript, and talk about all things related to Javascript, Ajax, and jQuery.
Killersites Forum » Javascript
9M ago
Hi guyz,
TypeScript vs. JavaScript - which one is better for the 2023 web applications ..read more
Killersites Forum » Javascript
9M ago
Hi guys,
How headless commerce revolutionized the world of mobile app development ..read more
Killersites Forum » Javascript
1y ago
Try to parse it and catch any failure. There isn’t a more fool-proof way to check if JSON is valid than that. Something like this would work:
function isValidJSON(s) {
try {
JSON.parse(s);
return true;
}
catch (e) {
}
return false;
}
// Run a few test cases:
console.log(`isValidJSON("4") = ${isValidJSON("4")}`); // prints true
console.log(`isValidJSON("[4") = ${isValidJSON("[4")}`); // prints false
console.log(`isValidJSON("[4]") = ${isValidJSON("[4]")}`); // prints true
  ..read more
Killersites Forum » Javascript
1y ago
Here is the example code to use an image as a button using JavaScript:
<html>
<head>
<style>
#mybutton{
cursor: pointer;
}
</style>
</head>
<body>
<img src="button_image.png" id="mybutton" onclick="submit();">
<form id=”myForm” action=””>
</form>
</body>
<script>
function submit(){
document.getElementById("myForm").submit();
}
</script>
</html>
  ..read more
Killersites Forum » Javascript
1y ago
/*
* Return the depth of recursive array a.
* Any array has a depth of at least one.
* Non-arrays always have a depth of zero.
*/
function arrayDepth(a) {
var depth = 0;
if (Array.isArray(a)) {
for (var i in a) {
depth = Math.max(depth, arrayDepth(a[i]));
}
depth++;
}
return depth;
}
  ..read more
Killersites Forum » Javascript
1y ago
Array[Position]; myJSON = '["Ford", "BMW", "Fiat"]'; myArray = JSON.Parse(myJSON); CarName =myArray[0];
  ..read more
Killersites Forum » Javascript
1y ago
String prefix=”prefix”; String suffix=”suffix”; StringBuilder str = new StringBuilder(prefix); str.append(suffix); // print string System.out.println("String = " + str.toString());
  ..read more
Killersites Forum » Javascript
2y ago
Hello everyone I wanted you all to look at this jQuery code to see how can I pass the data to the php file after the validation.
form.js ..read more
Killersites Forum » Javascript
2y ago
Hi,
I need to build this carousel but I have a lot of trouble making it responsive.
What I would like is when there are 3 cards in a slide when the button is pressed all 3 of them move out of the container and on mobile if there is only one card when the button is pressed only one should move.
I tried doing it by separating the big slide and the cards and run javascript for each using matchMedia() but I didn't even get to that as I have some other bugs.
Another problem I have is when the width of the windows is resized the first element is getting out of the view, plus for some reason, they do ..read more
Killersites Forum » Javascript
2y ago
Doing some great work to finally understand how to insert data into a database using JavaScript AJAX and PHP
But the problem I'm having is this, when inserting say a post (a basic commenting system is what I am doing just for a kind of proof of concept sort of thing so I can understand whats going on as such) it inserts the post but needing to refresh the page to see the new comment/post/data
Is there any better way of say doing this like so when inserting it automatically appears in the feed, have this essentially right now:
function getComments() {
var comments = document.getEle ..read more