osmtogeojson
osmtogeojson copied to clipboard
Conversion inside a second ajax call raises TypeError
TypeError: e.elements is undefined
[Learn More]
osmtogeojson.js:4:2503
n
http://localhost:8000/static/js/osmtogeojson.js:4:2503
u
http://localhost:8000/static/js/osmtogeojson.js:4:14818
success
http://localhost:8000/:235:36
i
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28012
fireWith
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28783
A
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:4:14033
c/<
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:4:16323
I am trying to pass a converted geojson data to another page. I did this using two ajax functions.
function sendQueryData(url, query){
url =url.replace('query' , query);
if (query === ""){
alert("City Input Required");
}else{
$.ajax({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
},
type: "POST",
url: "/search/pass/",
data: {
'query' : query
},
success: function(data){
$.ajax({
type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
url: url,
data: {
'feature': osmtogeojson(data)
},
success: function (data) {
window.location.href = url
}
});
}
});
}
}
I made sure that data is not null by alerting it.
Can you share an example of what data is returned by /search/pass/
in this code (i.e. what's inside the data
varaible when calling osmtogeojson(data)
)? Are you sure it is a valid OSM/Overpass JSON object?