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 ...
|
|||||||
|
|
#1 (permalink) |
|
Junior Member
Join Date: Apr 2009
Location: Denton, TX
Posts: 2
Rep Power: 0 ![]() |
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 |
|
|
|
| Sponsored Links | |
![]() |
| Bookmarks |
|
|
| Thread Tools | |
| Display Modes | |
|
|
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 |