Siple AJAX, of course

M

Monica Leko

Doesn't work. :)

I am using Google maps example from book, and from Google
documentation. It is really simple, and I don't know why isn't
working. My browser send mi this response:

This XML file does not appear to have any style information associated
with it. The document tree is shown below.
<markers id="id je ok">
<marker found="Keychain" lat="37.441" left="Book" lng="-122.141"/>
<marker found="Water Bottle" lat="37.322" left="Necklace"
lng="-121.213"/>
</markers>

My code is following
var getVars = "?q=" + search;
var request = GXmlHttp.create();
request.open('GET', '/lbs/' + getVars, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = request.responseXML;
alert(xmlDoc);
var responseNode = xmlDoc.getElementsByTagName('markers').item(0);
var type = responseNode.getAttribute("id");
}
}

responseXML allways sends back null value, although server sends back
XML. And, what I don't understanf (still newbie), after the alert
popups and write "null", my browser render upper XML file, instead
doing nothing and show page from which I called AJAX function. How
can this be?
 
T

Tom Cole

Doesn't work.  :)

I am using Google maps example from book, and from Google
documentation.  It is really simple, and I don't know why isn't
working.  My browser send mi this response:

This XML file does not appear to have any style information associated
with it. The document tree is shown below.
<markers id="id je ok">
<marker found="Keychain" lat="37.441" left="Book" lng="-122.141"/>
<marker found="Water Bottle" lat="37.322" left="Necklace"
lng="-121.213"/>
</markers>

My code is following
var getVars =  "?q=" + search;
var request = GXmlHttp.create();
request.open('GET', '/lbs/' + getVars, true);
request.onreadystatechange = function() {
  if (request.readyState == 4) {
    var xmlDoc = request.responseXML;
    alert(xmlDoc);
    var responseNode = xmlDoc.getElementsByTagName('markers').item(0);
    var type = responseNode.getAttribute("id");
  }

}

responseXML allways sends back null value, although server sends back
XML.  And, what I don't understanf (still newbie), after the alert
popups and write "null", my browser render upper XML file, instead
doing nothing and show page from which I called AJAX function.  How
can this be?

Does your server indeed return a valid XML document with content-type
of "text/xml" and what does the entire XML document look like?
 
M

Monica Leko

Does your server indeed return a valid XML document with content-type
of "text/xml" and what does the entire XML document look like?

There was a problem in my form tag. This was the oldest one:
<form method="GET" action="/lbs/" onSubmit="filterMarkers();false" >

And the current one is
<form method="GET" action="/lbs/" onsubmit="return filterMarkers()" >

Now everything works. Thanks anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top