Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Unhappy Help with testing

    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:

    Code:
    /* $.load(w, x, y, z) -- returns the requested file.
    
    PARAMETERS
    -----------------------------
    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) {
    				    a2(a1.responseText);
    				} else {
    				    if(a3 != false) {
    					    a3(a1.responseText);
    					}
    				}
    			}
    		}
    		httpRequest.onreadystatechange = f;
    	}
    	httpRequest.send(null);
    	if(!y) {
    	    x(httpRequest.responseText);
    	}
    	return httpRequest;
    };

  • #2
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Oh, and I forgot to mention: I keep getting an error and I don't know why.
    Error Message:
    Code:
    Expected (

  • #3
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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?

  • Users who have thanked venegal for this post:

    dev.genius (02-06-2011)

  • #4
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Good point.

  • #5
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Never mind with this post. I figured out what I was doing wrong.

  • #6
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •