View Full Version : Help with testing

02-06-2011, 06:18 PM
I'm working on a framework, and one of its most important parts is its Ajax module. Unfortunately, I am horrible with Ajax. I was just wondering if someone could help me with testing this.

Here is the code:

/* $.load(w, x, y, z) -- returns the requested file.

w - url of file to load
x - the callback function. Will be passed the reponse text as a parameter
y - Boolean value representing whether the connection should be synchronous
z - an optional function that will be called if an error occurs. Will be passed the response text as a parameter
var $ = {};
$.load = function(w, x, y, z) {
var httpRequest = function() {
if(window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
var t = ["MSXML2.XmlHttp.6.0", "MSXML2.XmlHttp.3.0"];
for (var i = 0; i < 2; i++) {
try {
var n = new ActiveXObject(t[i]);
return n;
} catch(e) {}
return null;
httpRequest.open("GET", w, y);
if(y) {
var a1 = httpRequest;
var a2 = x;
if(z) {
var a3 = z;
} else {
var a3 = false;
function f() {
if(a1.readyState == 4) {
if(a1.status == 200) {
} else {
if(a3 != false) {
httpRequest.onreadystatechange = f;
if(!y) {
return httpRequest;

02-06-2011, 07:00 PM
Oh, and I forgot to mention: I keep getting an error and I don't know why.
Error Message:

Expected (

02-06-2011, 07:01 PM
If you're writing your own framework, whose most important part is its AJAX module, isn't it sort of a prerequisite for you to *not* be horrible with AJAX?

02-06-2011, 07:09 PM
Good point.

02-06-2011, 07:09 PM
Never mind with this post. I figured out what I was doing wrong.

02-07-2011, 11:25 AM
I'd have thought a prerequisite for writing a JS framework, especially one that deals with AJAX, is thinking to yourself, "Hold on, there's chuffing hundreds of these things knocking about, almost all of which are going to be better written, better documented and better maintained than mine. I may as well save myself the bother and go and have a nice cup of tea and a sit down."