Skip to main content
Share Your Experience: Take the 2024 Developer Survey
7 votes
Accepted

Country Guessing Game

The screen design looks very nice. It is minimalistic, yet pleasing. It almost perfectly fits on the small screen of my phone (only sometimes, I have to scroll down to see all the answer buttons). The ...
Roland Illig's user avatar
  • 21.3k
6 votes

Country Guessing Game

Feedback Nice use of arrow functions, the fetch API (and associated promises), etc. The layout looks nice as well. Suggestions/Review Points Options could appear multiple times The code in ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
6 votes
Accepted

Upload and database insert php function

There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton For the life of me I wouldn't think of the ...
Your Common Sense's user avatar
5 votes

Refreshing / Cycling through a parsed RSS feed every 5 mins

I know this code is more than four years old and you haven't been on CR since then but maybe it will help somebody else. String concatenation and adding HTML elements The code adds a lot of HTML via ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
5 votes
Accepted

Simple inbox functionality using JavaScript and Ajax

Style guide I'd recommend picking a style guide to keep all of your whitespace consistent. I've formatted yours according to semistandard. Having a style guide could be considered a form of bike-...
Dan's user avatar
  • 3,748
5 votes
Accepted

Fast prototype code to hook up a webcam to the Azure Emotion API

Dealing with DOM document.getElement[s]By*(...) competes with $(...). Do not mix DOM accessing styles. That hurts readability. ...
Igor Soloydenko's user avatar
5 votes
Accepted

Loading html from file using JavaScript

I have some issues with your code and possible alternatives for implementation. Usage of var In Javascript using var instead ...
Tom Siwik's user avatar
  • 231
5 votes

Upload a user's avatar

Indentation First of all, format your code wisely. Do not make your main program body shifted by five levels of indentation. It makes it awfully hard to read (and review, mind you). Fail early. If ...
Your Common Sense's user avatar
5 votes

AJAX communication with pure JS and PHP

var ajax = new XMLHttpRequest(); ajax.open('POST', 'ajax.php?action=submit_form', true); You can replace XHR with fetch. ...
Joseph's user avatar
  • 25.1k
4 votes
Accepted

Make Simultaneous HTTP Requests That Resolve Into a Single Return

Compatibility aside, you can skip jQuery. Everything you need is present in vanilla JS. jQuery AJAX can be replaced by fetch and deferreds can be replaced by native ...
Joseph's user avatar
  • 25.1k
4 votes

Simple inbox functionality using JavaScript and Ajax

From a short review: I hope your id's are not simply an increasing number, otherwise this: ...
konijn's user avatar
  • 33.2k
4 votes
Accepted

Registration form validation in jQuery

Here is my take, dry some stuff. You can glue each piece of code together to have a working script (I guess). Keep track of your validations ...
Hugeen's user avatar
  • 303
4 votes
Accepted

Backbone.js dynamic table

As this question was asked nearly four years ago it is likely the case that you have learned more about JavaScript since then and/or changed this code. Nonetheless perhaps the info below will help you ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
4 votes
Accepted

Make loading icon appear only after 2 seconds

The ajaxStart() handler is only called if there are no other ajax requests currently in progress, so if there is already something in progress, the handler will ...
Mike Brant's user avatar
  • 9,608
4 votes

Securely calling PHP code from JavaScript

First of all your code has errors: echo JSON.encode("data" => eval($_GET['func'])); There's no JSON.encode in PHP. ...
insertusernamehere's user avatar
4 votes
Accepted

Returning the results of four $resource calls as a JSON array in AngularJS

Never, and I mean NEVER, manually construct JSON. That's just asking for trouble. Construct the object then use JSON.stringify. FYI, arrays are valid JSON so you ...
Joseph's user avatar
  • 25.1k
4 votes

Ajax Voting System

I'm only going to address the PHP and SQL code and the general voting mechanism. I can hardly imagine that multiple blog items share the same id. Therefor, the ...
Decent Dabbler's user avatar
4 votes
Accepted

Upvote/counter in Javascript

Consistency Sometimes you use snake_case and sometimes you use camelCase: in JavaScript we usually use camel case, it's not mandatory but stick to one. Then, for example, ...
Adriano Repetti's user avatar
4 votes

JS page loading without refresh

Danger Your approach to navigation is problematic an should be strictly limited to your own domain. Cross origin headers will prevent most requests being returned however do not make requests as 'no-...
Blindman67's user avatar
  • 22.1k
3 votes
Accepted

Creating chat box with comet

This code comes before the AJAX call. Is it right? I would suggest adding the message to the DOM via the success callback - that way, if an error occurs then the message isn't displayed on the page. ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
3 votes

Simple JavaScript quiz app using an external questions.json file

Some thoughts I like your approach with regards to separating display from logic. Keep thinking this way and you will end up with more re-usable and maintainable code. Since you are, in essence, ...
Mike Brant's user avatar
  • 9,608
3 votes
Accepted

Central ajax function in jquery

Central ajax function in jquery No. Just, no. It's tempting to handle how all AJAX operations are called in your app, but this is usually just for a handful of use cases. I've seen code time and ...
Joseph's user avatar
  • 25.1k
3 votes
Accepted

Custom function for serialization of form inputs (and selects)

You are not really implementing in plain JavaScript in that you are using jQuery inside the function. This seems to be an odd choice. Are you using jQuery or not? You should make a decision. If you ...
Mike Brant's user avatar
  • 9,608
3 votes
Accepted

POST to endpoint and GET data back

Avoid making multiple calls to express server, you can return filtered data from the POST call. Use single AJAX POST call. As your calls are being made parallel there is no way to know if the ...
Deep Vora's user avatar
  • 148
3 votes
Accepted

Basic PHP template loader

Technical mistakes echo void echo $tpl->render($_GET['tpl']); This echo will display empty string (null), because you've already output a string with echo ...
shudder's user avatar
  • 686
3 votes

Update game content via AJAX

My answer focuses on the ajax requests. Why 4 requests at each 1500 milliseconds to the same file (play.php)? I would do only one request and I would "cycle" on a ...
Louys Patrice Bessette's user avatar
3 votes

Update game content via AJAX

Louys already suggested simplifying the multiple requests into a single request - that is a great idea. I see a few other simplifications and suggestions. The first few lines of the Javascript code ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
3 votes

Effective to-do list in PHP and jQuery AJAX

General feedback Overall this code looks a bit repetitive - especially the PHP in index.php [top of the file] and the Javascript in general.js. Common lines could be abstracted into functions, and ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
3 votes

Replacement function for jQuery .post

I would: Use a FormData instead of creating a form element. Give it a name better than "postR", like... simply "post"? Add an error handler to the $.ajax call Unify both $.ajax calls Pseudo code (...
theonelucas's user avatar
3 votes
Accepted

Passing data to HTML template

First, let me review some of of the code you have ...
Your Common Sense's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible