|
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Every time I submit the POST request I receive an XMLHttpRequest Object which has a status of 0 and a value of NULL. My only thought is that I've entered the request incorrectly. When I send the http request manually with the uri string it displays the xml document just fine.
function getFullURL() {
var queryString0 = document.forms[0].lat.value;
var queryString1 = document.forms[0].lon.value;
var myData = "format=xml" + "&lat=" + encodeURIComponent(queryString0) + "&lon=" + encodeURIComponent(queryString1) + "&MaxResponse=1" + "&zoom=17" + "&accept-language=en-us" + "&addressdetails=1";
var myCompleteURL = myURL + myData;
return myCompleteURL;
}
function getMyData() {
var queryString0 = document.forms[0].lat.value;
var queryString1 = document.forms[0].lon.value;
var myData = "format=xml" + "&lat=" + encodeURIComponent(queryString0) + "&lon=" + encodeURIComponent(queryString1) + "&MaxResponse=1" + "&zoom=17" + "&accept-language=en-us" + "&addressdetails=1";
return myData;
}
function submitform() {
//concatenate post request into single string myData
var myCompleteURL = getFullURL();
var myData = getMyData();
alert(myURL);
var theLocation = document.getElementById("docs");
var text = document.createTextNode(myCompleteURL);
theLocation.appendChild(text);
//Post method with data. Protocol for success and failure.
OpenLayers.Request.POST({
url: myURL,
scope: this,
failure: requestFailure,
success: requestSuccess,
//headers: {'Content-Type': 'application/xml'},
data: myData
});
}
function requestSuccess(request) {
var format = new OpenLayers.Format.XML();
var myCompleteURL = getFullURL();
var myData = getMyData();
alert(request.status);
var doc = request.responseXML;
var theLocation = document.getElementById("docs");
var text = document.createTextNode(" " + doc);
theLocation.appendChild(text);
var output = format.getAttributeNS(doc,'*', '*');
alert(output[1]);
alert("2");
/* THE PROBLEM HAS TO BE IN THE NAMESPACE TYPE */
//appends the node in text form to element with id = docs in html form
xmlOutput = format.write(doc);
var theLocation = document.getElementById("docs");
var text = document.createTextNode(xmlOutput);
//theLocation.appendChild(text);
alert("paul");
//var output = format.getAttributeNS(;
if (output.responseLists[0]) {
var geometry = output.responseLists[0].features[0].geometry;
var foundPosition = new OpenLayers.LonLat(geometry.x, geometry.y).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
);
map.setCenter(foundPosition, 16);
} else {
alert("Sorry, no address found");
}
}
|
| Powered by Nabble | Edit this page |
