WordPress.org

Support

Support » How-To and Troubleshooting » Help with my first java script attempt

Help with my first java script attempt

  • I have extracted some js code from a working non-WordPress page, and I’m trying to make it work on my site. It defines a function and then executes a URL with a callback to that function. I can run the URL without the callback and I see the data I’m trying to access. It appears that the callback is not executing my function, as the data never gets displayes. Can someone help me get off square one? I’m a js novice, so be kind! 🙂

    Here are the entire contents of my page:

    <html>
    <head>
    </head>
    <script type="text/javascript" >
    function showEvents(json){
    var statusHTML = [];
    	for (var i=0; i<json.length; i++) {
    		var p = json[i];
    	    statusHTML.push('<table cellpadding="0" cellspacing="0">');
    		for (var j=0; j<p.length; j++) {
    			var sd = Date.parseDate(p[j].STARTDATE, "F, d Y g:i:s");
    		    statusHTML.push('<tr><td class="StartDate">'+ sd.dateFormat("F d") +'</td></tr>');
    		    statusHTML.push('<tr><td class="Event"><a href="##" onclick="goView('+p[j].EVENTID+');">'+p[j].EVENTNAME+'</a></td></tr>');
    		    statusHTML.push('<tr><td><hr size="1" color="#005daa"></td></tr>');
    		}
    	    statusHTML.push('</table>');
      	}
     document.getElementById('Events').innerHTML = statusHTML.join('');
    }
    statusHTML.push('</table>');
    }
    document.getElementById('Events').innerHTML = statusHTML.join('');
    }
    </script>
    <body>
    <p></p>
    <h3>EVENTS:</h3>
    <div id="Events">Loading...</div>
    
    <script src="http://www.IsMyRotaryClub.org/Event/Event.cfm?AccountID=6860&Mo=3&callback=showEvents" type="text/javascript">
    //<![CDATA[//]]>
    </script>
    </body>
    </html>

  • The topic ‘Help with my first java script attempt’ is closed to new replies.