global-scope

How to append text to a variable, within a function, in Javascript?

var err = ''; err += 'err a'; myString = 'Blah'; new Ajax.Request('/check_me.php', { method:'get', parameters: { 'string': myString }, evalScripts: true, onComplete: function(t){ var response = t.responseText; if (response == false) { //do nothing } else { err += 'err b.\n'; //alert(err); ...

ViewState Vs Session ... maintaining object through page lifecycle

Can someone please explain the difference between ViewState and Session? More specifically, I'd like to know the best way to keep an object available (continuously setting members through postbacks) throughout the lifecycle of my page. I currently use Sessions to do this, but I'm not sure if it's the best way. For example: SearchObje...

Share a JavaScript library's namespace or use your own?

It is fairly well known in JavaScript that declaring variables within the global scope is a bad thing. So code I tend to work on contains namespaced JavaScript. There seems to be two different approaches taken to this - Adding your application specific functions to the libraries' namespace e.g. $.myCarouselfunction Creating your own ...

Access private variable in global scope

For a school assignment I have to find a solution to the following problem; In this below code, the foo function in the global scope tries to access the private variables of a Box, which ofcourse doesn't work. I have to make the foo function work with one line of code at the place show code. #include <iostream> using namespace std; c...