Results 1 to 1 of 1
- 12-17-2007, 08:02 PM #1
Member
- Join Date
- Dec 2007
- Posts
- 1
- Rep Power
- 0
Problem reading an xml file with AJAX
I am trying to read the xml file that is retrieved with AJAX, I want to read the coordinates of the file. Below I show the function that creates the ajaxrequest object and the ajax call to the server. IE sends me the message error "object null" in the line where the "for" starts.
I dont know what the problem is. Any idea?
Thank you for your help.
function ajaxcoord(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
}catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
//alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var xml = ajaxRequest.responseXML.documentElement;
for (i = 0; i < xml.getElementsByTagName('SRS name').length; i++){
var item = xml.getElementsByTagName('CTS_Response')[i];
var txt = item.getElementsByTagName('COORDS values')[0].firstChild.data;
alert(txt);
}
}
}
ajaxRequest.open("GET","https://upd.geodatenzentrum.de/cts/server?REQUEST=GetCoordinates&FROMSRS=GEO84&TOSRS= GK3&COORDS=10 50 11 51",true);
ajaxRequest.send('');
}
Similar Threads
-
Reading file header
By mew in forum New To JavaReplies: 9Last Post: 02-19-2009, 07:29 PM -
Reading a File into ByteArray
By Java Tip in forum Java TipReplies: 0Last Post: 01-15-2008, 03:19 PM -
Reading a file
By mew in forum New To JavaReplies: 2Last Post: 12-30-2007, 12:23 PM -
Reading a file for use
By peachyco in forum New To JavaReplies: 2Last Post: 11-27-2007, 03:49 AM -
Reading from a file
By leebee in forum New To JavaReplies: 1Last Post: 07-23-2007, 12:02 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks