Skip to content

Instantly share code, notes, and snippets.

fooNamespace.foo = 'Not yet set.';
fooNamespace.setFoo = function(bar)
{
fooNamespace.foo=bar;
}
fooNamespace.outputFoo = function()
{
alert(fooNamespace.foo);
}
<html>
<head>
<title>Ajax JavaScript Includer</title>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
//We have to declare a global object that we will use as a namespace for storing
//the eval loaded functions and variables, otherwise they will only exist within
//the scope of the ajax response function, which is be useless.
<html>
<head>
<title>Ajax JavaScript Loader</title>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
//Sadly internalFunction can not be accessed here, only with the scope of the
//success function in which it was created using eval();
function nonScope()
{
<html>
<head>
<title>Ajax JavaScript Loader</title>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
//Sadly internalFunction can not be accessed here, only with the scope of the
//success function in which it was created using eval();
function nonScope()
{
var foo = 'test';
function setFoo(bar)
{
foo=bar;
}
function outputFoo()
{
alert(foo);
}
<html>
<head>
<title>Ajax JavaScript Includer</title>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
//The list of loaded resources.
var loaded = new Array();
function internalFunction()
{
alert("Success.");
}
<html>
<head>
<title>Ajax JavaScript Loader</title>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
$.ajax({type: "GET",
url: "1_loader.js",
success: function(responseText)
{