SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problems with wordpress and XMLHttpRequest... I think anyways. :)

    Server side programmer running into some client side problems... PLEASE HELP! AH!

    I'm using an AJAX event calendar for a website I'm building for a church, and I having problems returning the data recieved from the call to the .php page, back into the <div id="calendar></div>.

    I've ran it through FireBug, and it made the request successfully, and it'll show the data that it's grabbed, so I know it's at least calling the page, and grabbing what's in it. I'm just having problems getting that data to show up on the web page that's calling it.

    Here's the link to the development site:
    http://www.nlfe.org/wordpress/events

    Here's the javascript code that im using to make the request:

    Code JavaScript:
    var req;
     
    function navigate(month,year) {
    	var url = "wp-content/plugins/NewLife-EventCalendar/php/calendar.php?month="+month+"&year="+year;
    	if(window.XMLHttpRequest) {
    		req = new XMLHttpRequest();
    	} else if(window.ActiveXObject) {
    		req = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	req.open("GET", url, true);
    	req.onreadystatechange = callback;
    	req.send(null);
     
    }
     
    function callback() {	
     
    	if(req.readyState == 4) {
    		var response = req.responseXML;	
    		var resp = response.getElementsByTagName("response");
    		getObject("calendar").innerHTML = resp[0].getElementsByTagName("content")[0].childNodes[0].nodeValue;
    	}
    }
     
     
    function fade(amt) {
    	if(amt <= 100) {
    		setFade(amt);
    		amt += 10;
    		setTimeout("fade("+amt+")", 5);
        }
    }
     
    function showJump(obj) {
    	var curleft = curtop = 0;
    	if (obj.offsetParent) {
    		curleft = obj.offsetLeft
    		curtop = obj.offsetTop
    		while (obj = obj.offsetParent) {
    			curleft += obj.offsetLeft
    			curtop += obj.offsetTop
    		}
    	}
    	var jump = document.createElement("div");
    	jump.setAttribute("id","jump");
    	jump.style.position = "absolute";
    	jump.style.top = curtop+15+"px";
    	jump.style.left = curleft+"px";
    	var output = '<select id="month">\n';
    	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
     
    	var n;
    	for(var i=0;i<12;i++) {
    		n = ((i+1)<10)? '0'+(i+1):i+1;
    		output += '<option value="'+n+'">'+months[i]+'  </option>\n';
    	}
    	output += '</select> \n<select id="year">\n';
     
    	for(var i=0;i<=15;i++) {
    		n = (i<10)? '0'+i:i;
    		output += '<option value="20'+n+'">20'+n+'  </option>\n';
    	}
     
    	output += '</select> <a href="javascript:jumpTo()"><img src="/calendar/images/calGo.gif" alt="go" /></a> <a href="javascript:hideJump()"><img src="/calendar/images/calStop.gif" alt="close" /></a>';
    	jump.innerHTML = output;
    	document.body.appendChild(jump);
    }
     
    function hideJump() {
    	document.body.removeChild(getObject("jump"));	
    }
     
    function jumpTo() {
    	var m = getObject("month");
    	var y = getObject("year");
    navigate(m.options[m.selectedIndex].value,y.options[y.selectedIndex].value,'');
    	hideJump();
    }

    Any help would of course be deeply appriciated..

  2. #2
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    Found the solution:
    I changed:
    getObject("calendar").innerHTML = resp[0].getElementsByTagName("content")[0].childNodes[0].nodeValue;

    To this:
    document.getElementById("calendar").innerHTML = resp[0].getElementsByTagName("content")[0].childNodes[0].nodeValue;

  3. #3
    SitePoint Evangelist Dave Morton's Avatar
    Join Date
    Sep 2003
    Location
    Carson City, NV
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad to hear it, Matti. If there's anything else you need help with, don't hesitate to ask.

    By the way, I had a quick peek at your site there, and it looks very nice. My compliments.
    Making a difference, one little psychotic episode at a time
    Geek Cave Creations
    Beta testers needed for pChat
    Dave's Gallery

  4. #4
    SitePoint Zealot Timbothecat's Avatar
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very nice Matt. Did you design the theme too?

    I did notice something very strange btw... when I looked at the source code, I didn't see an opening body tag! I may have just missed it somehow.
    Linux Clustering: All nodes lead to /home.

  5. #5
    SitePoint Evangelist Dave Morton's Avatar
    Join Date
    Sep 2003
    Location
    Carson City, NV
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You didn't miss it. It's just not there. OOPS?
    The rest of the pages I looked at are ok, though.
    Making a difference, one little psychotic episode at a time
    Geek Cave Creations
    Beta testers needed for pChat
    Dave's Gallery


Bookmarks

Posting Permissions

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