Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Mogomra posted:

Here's a stupid question that doesn't deserve its own thread. What's the deal with "new," or rather not using it? What's the logic behind defaulting "this" to the window, or whatever the global object is? Why not default to "this" from the scope that the function was called? It's stupid, and there's no reason not to use "new" when it's needed, I just don't get why JavaScript does what it does when you leave it out.

Constructors are just regular functions. Understanding that fact will answer all your questions.

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Mogomra posted:

Here's a stupid question that doesn't deserve its own thread. What's the deal with "new," or rather not using it? What's the logic behind defaulting "this" to the window, or whatever the global object is? Why not default to "this" from the scope that the function was called? It's stupid, and there's no reason not to use "new" when it's needed, I just don't get why JavaScript does what it does when you leave it out.

It defaults to undefined in strict mode. Dynamic scope is a trap and hard to optimize, though, so no. ES6 will have the lexical this you're used to with arrow functions.

Mogomra
Nov 5, 2005

simply having a wonderful time
I get that, I really do. I just don't understand why these to things end up being the same.

code:

function Thing1 () {
  // do stuff to 'this'
  this.Lol = "butte";
}

// I'm messing around with the window object
Thing1();

// ===================================

function Thing2 () {
  this.isRad = true;
}

function Thing3 () {
  // But why is Thing2's 'this' still window? Why not the instance of Thing3 that called it or something?
  Thing2();
}

// Thing2 still operates on window
new Thing3();

I get that you should use Function.call() or . apply() in that case, but why does it always default to the global object if you don't? I guess the more I think about it, each function is part of the window object, but then what happens if I do something like:
code:

Thing3.Thing4 = window.Thing4 = function () { ... };
Thing3.Thing5 = function () { ... };

Would 'this' also end up being window if you don't use new?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Mogomra posted:

Would 'this' also end up being window if you don't use new?

JS does not have lexical closures, it's based on the syntax of how you called the object.

If you do o.f();, this is o.

If you do var f = o.f; f();, this is the global object.

If you do new f(); or new o.f();, this is an object constructed from the constructor's prototype property. Imagine var this = Object.create(Thing.prototype); at the top of your constructor function.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





JOHN SKELETON posted:

The company I work for uses this pattern:

JavaScript code:
var SuperClass = function(param){
    this.param = param;
};

var Subclass = function(param){
    SuperClass.call(this, param);
    this.whatever = 1;
};

var instance = new Subclass('butt');
I've been wondering if it has any downsides compared to these other ways of implementing inheritance in JS. I think it looks nicer. You can even do an arbitrary amount of logic before you inherit stuff from the SuperClass, which is sort of useful.

Your company are a bunch of monsters for capitalizing SuperClass but not Subclass.

But seriously, this doesn't work. This doesn't allow SubClass to inherit any properties of SuperClass.

JavaScript code:
SuperClass.prototype.hello = function() { return "hello" }
SubClass.prototype.bye = function() { return "goodbye" }

var instance1 = new SubClass('butt')
var instance2 = new SuperClass('butt')

console.log(instance1.hello()) // errors out
console.log(instance2.hello()) // "hello"

console.log (instance1 instanceof SubClass) // returns false; should be true

Mogomra
Nov 5, 2005

simply having a wonderful time

Suspicious Dish posted:

JS does not have lexical closures, it's based on the syntax of how you called the object.

If you do o.f();, this is o.

If you do var f = o.f; f();, this is the global object.

This answers the question I was asking pretty clearly. Thanks!

TURTLE SLUT
Dec 12, 2005

Strong Sauce posted:

Your company are a bunch of monsters for capitalizing SuperClass but not Subclass.

But seriously, this doesn't work. This doesn't allow SubClass to inherit any properties of SuperClass.

JavaScript code:
SuperClass.prototype.hello = function() { return "hello" }
SubClass.prototype.bye = function() { return "goodbye" }

var instance1 = new SubClass('butt')
var instance2 = new SuperClass('butt')

console.log(instance1.hello()) // errors out
console.log(instance2.hello()) // "hello"

console.log (instance1 instanceof SubClass) // returns false; should be true

It most definitely works, we just never use classname.prototype for anything.
JavaScript code:

var SuperClass = function(value){
    var self = this;

    self.value = value;
    this.myClassName = 'SuperClass';

    this.sayName = function(){
        console.log('My class name is:', self.myClassName);
    } 
};

var SubClass = function(value){
    var self = this;

    SuperClass.call(this, value);
    this.myClassName = 'SubClass';
};

var superc = new SuperClass(2);
var subc = new SubClass(4);

console.log(superc.value);
superc.sayName();

console.log(subc.value);
subc.sayName();
edit: Oh did you mean to say that the subclasses aren't counted as instances of the superclass? I guess that's a real problem, but I'll have to dive into our codebase a little bit more to see if our convention solves some problems prototypes don't. I have a feeling we have some important logic in some SubClasses before the SuperClass.call(this) is done.

TURTLE SLUT fucked around with this message at 03:07 on Oct 23, 2013

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The problem with that approach is it creates a new copy of each function for each instance of the class, which massively increases memory usage. From a design perspective I'm a fan since it means you get private variables, but it just doesn't scale very well.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Plorkyeran posted:

The problem with that approach is it creates a new copy of each function for each instance of the class, which massively increases memory usage. From a design perspective I'm a fan since it means you get private variables, but it just doesn't scale very well.

This isn't quite true. Functions aren't duplicated; bodies are compiled once and then closed over at runtime. All that means is that you have a new closure, of which the scope chain is shared between all the other methods in the body, which isn't too big an issue with memory consumption. The "hidden class"-type analysis most engines do nowadays also work to identify this pattern.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The big thing is that now each object has a pointer to every single method (instead of what is effectively a vtable pointer to the prototype), which is quite a lot of bloat for classes with a lot of methods and not many data fields.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Suspicious Dish posted:

This isn't quite true. Functions aren't duplicated; bodies are compiled once and then closed over at runtime. All that means is that you have a new closure, of which the scope chain is shared between all the other methods in the body, which isn't too big an issue with memory consumption. The "hidden class"-type analysis most engines do nowadays also work to identify this pattern.

If you do what JOHN SKELETON is doing, you still need to create objects and allocate space for them. But now you are also allocating the space for functions instead of just having the objects reference the prototype.

Hidden classes AFAIK just speed property lookups by using offsets to the current object being created rather than using a lookup table.

So what I mean is, if you have
JavaScript code:
function Obj(foo, bar) {
  this.foo = foo
  this.bar = bar
}
var A = new Obj(1, 2), B = new Obj(3, 4)
All hidden classes do is tell the compiler the offset from where an Obj object is created to where Obj.foo and Obj.bar are held rather than have a table in memory that point to where its Obj.foo and Obj.bar are. A and B in this case don't share properties, they only share internally where to look for the values of foo/bar with respect to where A and B are located in memory.

jackpot
Aug 31, 2004

First cousin to the Black Rabbit himself. Such was Woundwort's monument...and perhaps it would not have displeased him.<
I'm having trouble with the simplest thing: Two divs, hidden at first. Two radio buttons: Option 1, Option 2. Clicking option 1 shows div 1 (and hides div 2 if it's open), and clicking option 2 shows div 2 (and hides div 1). I've googled the poo poo out of javascript examples but am having a hell of a time making anything work how I want.

This is what I want, but I'm working inside someone's workpress contact form, and I can't figure out if I have enough control to do this.

http://jsfiddle.net/HREqE/

It's the kind of thing where I've got a dropdown and I choose "radio" - it generates this, and I'm adding the data-rel at the end. Soon as the data-rel goes in there, the saved page won't show the radios. This is why I don't enjoy working on wordpress sites.

jackpot fucked around with this message at 22:54 on Oct 25, 2013

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
You don't need to save the page in order to look at the HTML as it's being rendered - just press F12 in any non-poo poo browser.

Dren
Jan 5, 2001

Pillbug
I'm writing a module using the following pattern:
JavaScript code:
var module = (function() {
  var privates = {
    ...
  };

  var publics = {
    ...
  };

  return publics;
}());
Is there a way to access the module's private functions from my unit test code? I feel like the answer is no and that I probably need to do something like this:
JavaScript code:
var module_private = {
  ...
};

var module = (function(privates) {

  var publics = {
    ...
  };

  return publics;
}(module_private));
Anyone have any pointers?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
No, you really cannot poke into closures like this. In my idealist view, if your unit tests needs to poke into internal state, it shouldn't be internal. Maybe public isn't appropriate, but perhaps it can be namespace-private like Python has, by prefixing "secret" data with an underscore, by convention?

Dren
Jan 5, 2001

Pillbug
That's a good idea. I'm pretty sure the answer to this is yes but are closures the only way to control visibility in js?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Until private name objects arrive in engines, yes.

nuts_rice
Sep 6, 2010

Ohhh Yog Soggoth, be my teenage dream boat ;)
I realize this maybe isn't the best thread, but I wanted to start a project to learn javascript.
I really enjoy cryptography, as I really loved number theory in my Discrete Math classes.
So, I'm trying to figure out a neat project with js to maybe be some sort of RSA encrytor or something, but I'm kinda at a lost for ideas.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Have you written an encryptor in another language? Try doing a line-by-line straightforward port of it to JS.
Next, read a book or two on JS and see if you can't go back and do it again with a better understanding of scope and prototypes and perhaps a library like Parallel.js

DholmbladRU
May 4, 2006
I am creating a visualization using google maps api v3. One of the big components is to be able to render polygons which 'outline' regions such as zip code, state.... This needs to be done dynamically so kml files or fusion tables wont work. So I have data for each type of polygon I want to render, this data was initially in Json format. My application can consume this format and render polygons. I found that rendering ~3000 polygons took about 8 seconds. Not terrible but I thought I could make it quicker. To make it quicker I decided to "prebuild" the google maps api syntax necessary to render each polygon, this would be stored in a database. Once its stored in a database I am using restful web services to bring back these values.

https://www.applicatin.com/giveZip&val=22031

Now my problem is storing these google polygons in the database with a few hundred points is a difficult thing to do. It seems like some of the syntax is unnecessary such as repeating 'new google.maps.LatLng' for every single point.

How can I simplify these polygons syntax?


note I am a pretty big novice when it comes to javascript

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy
I've built KML files dynamically. It's not that hard as long as you have good XML support in your server-side language. I made the maps in Google Earth, split them up programmatically, and recombined them based upon user selections.

DholmbladRU
May 4, 2006
Is that a faster approach than what I am doing?

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

DholmbladRU posted:

Is that a faster approach than what I am doing?

It seems to be pretty speedy, considering that Google downloads your KML and translates it into a map overlay. But I haven't rendered 3000 polygons that way, I was doing lines and placemarks.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

DholmbladRU posted:

To make it quicker I decided to "prebuild" the google maps api syntax necessary to render each polygon, this would be stored in a database.

Why did you choose to do this? Did you benchmark and determine that reading in your JSON was the bottleneck in your code?

excidium
Oct 24, 2004

Tambahawk Soars
AngularJS + JSON question: I'm trying to use the orderBy filter on my ngRepeat. The structure of my JSON looks like this

pre:
{
	"properties": {
		"name": "Risk",
		"caption": "Risk",
		"readOnly": 0
	},
	"Risk": [
	    {
	        "id": 0,
	        "RiskOutput.Address": {
	            "value": "490 Wythe Avenue, Bordelonville, South Dakota, 9771",
	            "caption": "Address",
	            "maxLength": 100,
	            "required": false,
	            "applicable": true,
	            "readOnly": true,
	            "annotations": true
	        },
	        "RiskOutput.Description": {
	            "value": "Location #65",
	            "caption": "Location",
	            "maxLength": 30,
	            "required": false,
	            "applicable": false,
	            "readOnly": true,
	            "annotations": true
	        },
	        "RiskOutput.ID": {
	            "value": "e487ac57-8de8-4794-b562-ff5556eda79f",
	            "caption": "ID",
	            "maxLength": 50,
	            "required": false,
	            "applicable": false,
	            "readOnly": false,
	            "annotations": true
	        }
	    },
	    {
	        "id": 1,
	        "RiskOutput.Address": {
	            "value": "136 Lawrence Avenue, Statenville, North Carolina, 7118",
	            "caption": "Address",
	            "maxLength": 100,
	            "required": true,
	            "applicable": true,
	            "readOnly": false,
	            "annotations": true
	        },
	        "RiskOutput.Description": {
	            "value": "Location #37",
	            "caption": "Location",
	            "maxLength": 30,
	            "required": false,
	            "applicable": false,
	            "readOnly": false,
	            "annotations": true
	        },
	        "RiskOutput.ID": {
	            "value": "4d582882-d462-45c3-b049-5e8a052f46d2",
	            "caption": "ID",
	            "maxLength": 50,
	            "required": true,
	            "applicable": true,
	            "readOnly": true,
	            "annotations": true
	        }
	    },
etc...
My code on the page looks like this
pre:
<tr ng-repeat="risk in pageData.Risk | orderBy:'[RiskOutput.Description].value'">
   <td>{{risk["RiskOutput.ID"].value}}</td>
   <td>{{risk["RiskOutput.Description"].value}}</td>
   <td>{{risk["RiskOutput.Address"].value}}</td>
   <td class="btn-toolbar"><button class="btn btn-xs btn-primary">Edit</button> <button class="btn btn-xs btn-danger">Delete</button></td>
</tr>
Anything I try for the orderBy fails to sort anything. What I want is to be able to sort on any of the 3 table columns; ID, Description or Address. Any insight into what I'm doing wrong?

bobua
Mar 23, 2003
I'd trade it all for just a little more.

In node.js\express(but probably a javascript question):

Why is it that if I use

code:
app.post('/login_form_action', function(req,res){
    login.login_handler(req, res, dynode)
});
All is well, but when I try

code:
app.post('/login_form_action', login.login_handler(req, res, dynode));
req and res are considered undefined?

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



bobua posted:

In node.js\express(but probably a javascript question):

Why is it that if I use

code:
app.post('/login_form_action', function(req,res){
    login.login_handler(req, res, dynode)
});
All is well, but when I try

code:
app.post('/login_form_action', login.login_handler(req, res, dynode));
req and res are considered undefined?

When you do "function(req, rest){ login.login_handler(req, res, dynode);)" you're creating a function that takes two parameters and returns whatever value "login.login_handler(req, res, dynode)" returns, when you do "app.post('/login_form_action', login.login_handler(req, res, dynode));" you're giving the second parameter as the return value of a function that is evaluated immediately (more or less), so it looks up req and res since it expects those to be variables in scope at that time and gets confused because there isn't anything there, because they don't exist yet.

Look up closures because I'm pretty sure that's what this is (I'm poo poo at remembering the proper terms for what's going on).

The best way to think about it is that in your first example you're passing "app.post(...)" an object that represents a function and is called later when it's needed (and when req and res exist) while in the second one you're calling a function outright and it expects the variables it needs to exist right there and then.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





bobua posted:

In node.js\express(but probably a javascript question):

Why is it that if I use

code:
app.post('/login_form_action', function(req,res){
    login.login_handler(req, res, dynode)
});
All is well, but when I try

code:
app.post('/login_form_action', login.login_handler(req, res, dynode));
req and res are considered undefined?

It's simple. In the first one you are passing in a function, the second one you are passing in a functional call that returns something (which could be valid if your function returns a function).

req and res don't exist in scope in the 2nd example, thus they have undefined values. What you should be passing is the function, login.login_handler, without any parameters.

Keep in mind, the callbacks in express actually have a signature of: function(req, res, next, error), so if dynode is not passing down the express handler via next(), then you cannot actually pass in 'login.login_handler' as a function because that will actually hang your application.

bobua
Mar 23, 2003
I'd trade it all for just a little more.

I'm still confused. I thought app.post provided the req\res variable. If I'm 'creating' those variables with function(req,res) {... Then what is populating them with data? When I use them in the login handler function, they contain the info I'm looking for(req.body.email for example).

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



bobua posted:

I'm still confused. I thought app.post provided the req\res variable. If I'm 'creating' those variables with function(req,res) {... Then what is populating them with data? When I use them in the login handler function, they contain the info I'm looking for(req.body.email for example).

In your first example you're creating a function that calls that login function and giving the new function to app.post to use later, later on app.post will call that new function with a res and req in scope.

In your second example you're calling the login function as the second parameter to app.post, the javascript interpreter will look at that and go "oh they want to call a function, let's evaluate that function now and use the return value as the second parameter to app.post", but calling it now doesn't make sense and res and req don't exist in it's scope (since they exist only inside what app.post calls) so it won't work. What you want to be doing there is giving app.post the function you want to call when it's time for app.post to call a function, you have to have some construct in the language that tells the interpreter that you're passing the actual function to app.post and not just calling that function, the way to do that is to use function(){} to create a new function and have it contain the logic you want to run later when app.post uses your callback function.

What you want to do is pass app.post a callback function -- a function that takes the right number of parameters and can be used by app.post later on for it's own nefarious purposes, the names res and req don't have any relevance either actually, you can name the parameters to that new function poop and fart and it'll still work, the new function is just a function beng returned that takes two parameters.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





bobua posted:

I'm still confused. I thought app.post provided the req\res variable. If I'm 'creating' those variables with function(req,res) {... Then what is populating them with data? When I use them in the login handler function, they contain the info I'm looking for(req.body.email for example).
You are misunderstanding two things.

The first is variable scoping. The second is not knowing that javascript can pass a function as a parameter because in javascript they are first class citizens.

In your first example, you are passing a string and then a function as the two parameters, the second example you are passing a string and a return value of whatever login.login_handler is suppose to return.

Since in the second example you are executing a function call, it needs to pass values into the login.login_handler to get a return result. But when you do that, javascript needs to resolve req and res, which do not exist in the current scope. So they will pass undefined to the login.login_handler function.

You need to ignore the fact that in the first example the function name passes two parameters called req and res. Because that is irrelevant. You instead need to look at it as a function that passes two parameters.

Callbacks, closures, and functions as first-class citizens are important concepts you need to learn in javascript. So if they don't seem clear, you may want to look them up in a book or online to understand them further.

bobua
Mar 23, 2003
I'd trade it all for just a little more.

Think my minds on the right track now, than you gentlemen. Just dove into Javascript: The good parts, which may be a little dated since it came out in 2008 but between that and google I think I'll be okay, unless there is a book you all recommend.

rsjr
Nov 2, 2002

yay for protoss being so simple that retards can win with it

bobua posted:

Think my minds on the right track now, than you gentlemen. Just dove into java script: The good parts, which may be a little dated since it came out in 2008 but between that and google I think I'll be okay, unless there is a book you all recommend.

I really hated The Good Parts. I'd suggest reading the MDN documentation and buying Effective: Javascript by David Herman.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

excidium posted:

AngularJS + JSON question: I'm trying to use the orderBy filter on my ngRepeat. The structure of my JSON looks like this

pre:
{
	"properties": {
		"name": "Risk",
		"caption": "Risk",
		"readOnly": 0
	},
	"Risk": [
	    {
	        "id": 0,
	        "RiskOutput.Address": {
	            "value": "490 Wythe Avenue, Bordelonville, South Dakota, 9771",
	            "caption": "Address",
	            "maxLength": 100,
	            "required": false,
	            "applicable": true,
	            "readOnly": true,
	            "annotations": true
	        },
	        "RiskOutput.Description": {
	            "value": "Location #65",
	            "caption": "Location",
	            "maxLength": 30,
	            "required": false,
	            "applicable": false,
	            "readOnly": true,
	            "annotations": true
	        },
	        "RiskOutput.ID": {
	            "value": "e487ac57-8de8-4794-b562-ff5556eda79f",
	            "caption": "ID",
	            "maxLength": 50,
	            "required": false,
	            "applicable": false,
	            "readOnly": false,
	            "annotations": true
	        }
	    },
	    {
	        "id": 1,
	        "RiskOutput.Address": {
	            "value": "136 Lawrence Avenue, Statenville, North Carolina, 7118",
	            "caption": "Address",
	            "maxLength": 100,
	            "required": true,
	            "applicable": true,
	            "readOnly": false,
	            "annotations": true
	        },
	        "RiskOutput.Description": {
	            "value": "Location #37",
	            "caption": "Location",
	            "maxLength": 30,
	            "required": false,
	            "applicable": false,
	            "readOnly": false,
	            "annotations": true
	        },
	        "RiskOutput.ID": {
	            "value": "4d582882-d462-45c3-b049-5e8a052f46d2",
	            "caption": "ID",
	            "maxLength": 50,
	            "required": true,
	            "applicable": true,
	            "readOnly": true,
	            "annotations": true
	        }
	    },
etc...
My code on the page looks like this
pre:
<tr ng-repeat="risk in pageData.Risk | orderBy:'[RiskOutput.Description].value'">
   <td>{{risk["RiskOutput.ID"].value}}</td>
   <td>{{risk["RiskOutput.Description"].value}}</td>
   <td>{{risk["RiskOutput.Address"].value}}</td>
   <td class="btn-toolbar"><button class="btn btn-xs btn-primary">Edit</button> <button class="btn btn-xs btn-danger">Delete</button></td>
</tr>
Anything I try for the orderBy fails to sort anything. What I want is to be able to sort on any of the 3 table columns; ID, Description or Address. Any insight into what I'm doing wrong?

Your object keys are really janky for working with angulars filters, so this may not work, but try escaping the inner key:

"orderBy:'[\'RiskOutput.Description\'].value'"

If that fails I think you should remove the dots in your keys so you can access the attributes without the square bracket notation. ie riskOutputDescription or something similar. That way you could use

order by: riskOutputDescription.value

Alternatively you can create a getter function in scope that will take your object and return the description value for sorting. Give that function to orderBy.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

rsjr posted:

I really hated The Good Parts. I'd suggest reading the MDN documentation and buying Effective: Javascript by David Herman.

Counterpoint: I really loved The Good Parts. I'd suggest reading it many times, as well as reading MDN docs.

Pollyanna
Mar 5, 2005

Milk's on them.


So I'm gonna begin using Knockout.js for a small website project. It's not going to be much more than a button to click and some text boxes that appear. Do I need to learn anything more complicated like AJAX or whatever, or is just going through the KO documentation/tutorial enough?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Pollyanna posted:

Do I need to learn anything more complicated like AJAX or whatever, or is just going through the KO documentation/tutorial enough?

AJAX is only for talking to a server without reloading the page. If you don't have a need for that, then you shouldn't have to learn it.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
edit: whoops I should probably put this in the jQuery thread

fletcher fucked around with this message at 23:59 on Nov 4, 2013

Pollyanna
Mar 5, 2005

Milk's on them.


Bognar posted:

AJAX is only for talking to a server without reloading the page. If you don't have a need for that, then you shouldn't have to learn it.

Ahh, right. My page isn't going to be handling a whole lot of data or keeping a database or anything, so I don't foresee the need to keep querying the server to load data.

That reminds me, I'm wondering whether Knockout or jQuery is the best way to go about my project. Knockout appears to be good for forms and emails and stuff, which isn't really what I'm going to do - it's probably just going to be a counter, basic animation and some graphics. Is Knockout really the best tool for this, or should I use something that's more appropriate?

Adbot
ADBOT LOVES YOU

bobua
Mar 23, 2003
I'd trade it all for just a little more.

Speaking of AJAX(which I've never used)... Let's say you wanted a little message box on a page, and you wanted the server to be able to send messages to that box at any time, not just when the user clicks a button or something on the page. Would AJAX be the right avenue for that sort of thing? I went through the w3c's AJAX tutorial and it seemed close, but all of the examples were more about the page setting up a request and waiting for a response.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply