Jump to content

thescientist

Moderator
  • Posts

    8,682
  • Joined

  • Last visited

Everything posted by thescientist

  1. can you please post the exact code you are using?
  2. can you be more specific? are you only seeing a white page? maybe the site was down at the time, did you check the networks tab / error console? Did the site load by maybe not the CSS or JS? Also, by site are you referring to the forums or the actual w3schools.com site?
  3. for simple logging Javascript console.log("i made it here"); PHP echo "i made it here too"; For request / response, use the browsers developers tools and the network tab. All requests going out from the browser will be there and you can see if they were successful or not
  4. Are you looking in the error console of your browser? Check to see if the request for the file is going out and what the response is. I would also add logging to your PHP and Javascript so you can trace the execution of the code.
  5. I wouldn't say that necessarily. Specification can be different from implementation, and different run times can "decorate" the language specification alltogether. For example, consider these different runtimes NodeJS - JavaScript (V8, no DOM for example) Browser - JavaScipt Flash - ActionScript
  6. You didn't actually explain what wasn't working, so my first guess is because you're trying to add strings. Try "casting" them to integers instead. http://www.w3schools.com/jsref/jsref_parseint.asp var x = parseInt(document.getElementById( "a" ).value, 10); var y = parseInt(document.getElementById( 'b' ).value, 10);
  7. This? https://developer.mozilla.org/en-US/docs/Web/API/Window Or do you mean like in a browser? If so, you can log the window object to the console, and expand all the properties / methods that way.
  8. Make sure you understand what the DOM (Document Object Model) is first. https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model You are dealing with a browser API that give you access to the markup / structure of the page in a programmatic way.
  9. not sure if you are poking fun, but that's pretty much all ES6. Also, JSX is not required in order to use React. You can just write HTML in the render function instead.
  10. Are you referring to JSX? I thought so too, but I got over it pretty fast. For me, React components in ES6 look very nice. Here's an example from one of my projects https://github.com/thescientist13/github-dashboard/ 'use strict'; import React from 'react'; import './user-details.css!'; import { GithubStore } from '../../stores/github/github-store'; class UserDetails extends React.Component { constructor() { super(); this.state = { avatar: '', name: '' }; this.getUserDetails(); } getUserDetails() { let store = new GithubStore(); store.getUserDetails().then(response => { this.setState(response.data); }); } render() { return ( <div className="user-details"> <img className="user-avatar img-responsive" src={this.state.avatar}/> <h1><span className="user-name">{this.state.name}</span></h1> </div> ) } } export default UserDetails; I like Angular syntax too, in particular when using TS. That said, not every tool is for everyone, and I always defer to the team / project / situation.
  11. I'll only add that although jQuery is helpful in the situations where cross-browser support is required for very old browsers and also for some of it's other nice API's, in general these days I think it is more beneficial to point new developers to native first solutions, especially in teaching exercises like this. If the developer gets into a position where the time spent costs more than the pro / cons of just pulling in jQuery because of some constraint not self-imposed, then that's a time to consider it. Additionally, as an application grows, a developer might instead favor looking into libraries and frameworks like React or Angular to help scale their application, bypassing jQuery altogether in favor of trading some opinionation and the cost including a dependency for quicker and more focused development. The cons of having to pull in a big toolbox or negated these days by more frameworks and libraries being built in a modular fashion, so you only pull in what you need, rather than a monolith. Personally, I find myself writing as much vanilla ES6 as possible, leveraging something like Babel, or the TypeScript compiler (and / or writing TypeScipt). Tools like React, Angular 2, and Aurelia have very small footprints in the actual source code itself, as they let you use just extend their module using ES6 class syntax. To sum it up, just use the right tool for the job, but for learning, I think vanilla ES6 is the way to go.
  12. the code itself looks incorrectly written. isset is being used against $page, but the variable assigned to $_GET['page'] is $file, and then this undefined $page variable is being used in the include.
  13. version control systems can be especially useful for avoiding these kinds of hazards
  14. I think the important thing here to keep in mind for the OP is not just looking for development environment, but simple distribution pipeline as well. For that reason, I would still recommend Node. You can continue to write in JS, there are installers for Windows / OSX that anybody can install from to keep that overhead low, and it comes with a package manager. On top of that, you can use Node / NPM to install a webserver for users as well. All in all, it provides a very robust ecosystem for developers, and a pretty straightforward consumption process for users.
  15. No, that's not a problem per se. It's just that writing code and distributing code are different objectives and often involve different skill sets, especially if you are specifically targeting desktop users. That said, it's more of a disclaimer is all. Have you heard of Node? It is a JavaScript runtime (akin to what you get when running JavaScript in the browser) except that it is a program that you can have your users install ahead of time and can be run on their own machines, like a native app. From there, you could publish this project to NPM and then users could also use it to install your project (with all its source and dependencies) and from there a single command could be run in order to launch your app. Any reason you are favoring desktop vs. the web though?
  16. Is this just for something you are doing on your own, or something you are looking to share with other people, so they can run it too?
  17. I think the problem here is that you intentionally bought the DIY model, but for whatever reasons aren't understanding what that actually entails. When I taught myself how to setup Linux servers for my CI environment, yes most of the time I got lucky and installing Java, Jenkins, Node, Apache, PHP etc just worked, but then when I wanted to configure VHosts and routing and all that jazz and I stumbled and some things didn't worked right out of the box. My first reaction was not to blame the tools or the author's right off the bat, since I was the n00b, it had to be on me to resolve and do the leg work first to make sure I was following the instructions and paying careful attention to the errors I was seeing, as I was the one doing it for the first time. Sure documentation wasn't always the most natural or intuitive, but eventually I just had to find the right command and then it worked, and I learned more along the way.
  18. When you say on your desktop, what do you mean? A native application or running in a web browser?
  19. If you use an editor with syntax highlighting, or put that snippet in code blocks, you might see the issue that DaveJ is referring too <!DOCTYPE html> <html> <head> </head> <body> <p id="p1">Test 1</p> <button type="button" onclick="myTest()">myTest()</button> <button type="button" onclick="alert(document.hasFocus())">hasFocus()</button> <button type="button" onclick="alert(document.getElementById("p1").tagName)">getElementById()</button> <script> function myTest() { alert(document.getElementById("p1").tagName); } </script> </body> </html>
  20. I usually don't even bother with the button. It's just easier to set the bbcode tags myself, eg. [ code] function showCodeSnippet() { //my code will go here } [/ code] (again don't include the space before code)
  21. The markup syntax is typically to surround it with brackets, eg [ code] code here [/ code] (spaces before code intentional). There is also a button for inserting it, the < > button.
  22. why are you calling it myPDO? The name of the class is PDO http://php.net/manual/en/book.pdo.php
  23. event handlers are covered in a couple different sections within the w3schools JS tutorial http://www.w3schools.com/js/default.asp
×
×
  • Create New...