AJAX Forums

XMLHttpRequest not working?

This is a discussion on XMLHttpRequest not working? within the AJAX Questions forums, part of the Beginners AJAX category; Hello - I'm new to AJAX and am experiencing a problem with my XMLHttp Request. This is the error I keep receiving: Error: xmlDoc is undefined Source File: videoSearch. js ...

Go Back   AJAX Forums > Beginners AJAX > AJAX Questions

AJAX Made Easy


AJAX Questions Ask Ajax Questions Here!

Reply

 

LinkBack Thread Tools Display Modes
Old 04-15-2009, 12:59 PM   #1 (permalink)
Junior Member
 
Join Date: Apr 2009
Location: Denton, TX
Posts: 2
Rep Power: 0
btate is on a distinguished road
XMLHttpRequest not working?

Hello -

I'm new to AJAX and am experiencing a problem with my XMLHttp Request. This is the error I keep receiving:

Error: xmlDoc is undefined
Source File: videoSearch.js Line 7

Here is the code for the source file:

function searchVideos() {

var xmlDoc=loadXMLDoc();

var x=xmlDoc.getElementsByTagName("videoIndex")[0];
var y=x.childNodes[0];
document.write(y.nodeValue);

}

function loadXMLDoc() {
var Request = false;
if (window.XMLHttpRequest) {
// Try FireFox, Safari, Opera, IE 7 or higher
Request = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// Try ActiveX (IE 5 or 6)
Request = new ActiveXObject("Microsoft.XMLHTTP");
}

if (Request) {
Request.open("GET", "videoLibrary.xml");
Request.onreadystatechange = function() {
if (Request.readyState == 4 && Request.status == 200) {

var xmlDoc = Request.responseXML;
return(xmlDoc);

}
}
Request.send(null);
}
}

-------------------------- End Code ---------------------

I'm calling the searchVideos() function with <a href="javascript:function()"> in an HTML page. If the code was working properly, it should return a value of 1. Can anyone help me?

--

Thanks,
btate
btate is offline   Reply With Quote
Sponsored Links
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
AJax code is working in india but bot working in Germany nirajkg04 AJAX Ideas 1 06-10-2008 09:17 AM
Creating the XMLHTTPRequest javarunner AJAX Questions 1 05-23-2008 03:11 PM
XMLHttpRequest - Security Bypass prabhu AJAX Articles 0 12-23-2006 07:07 AM
Fixing AJAX: XMLHttpRequest Considered Harmful Ajaxking AJAX Articles 0 12-17-2006 10:07 PM


All times are GMT -4. The time now is 11:17 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0
Copyright ©2006 - 2009, AJAXwith.com