引发TypeError的jQuery Ajax
我很难弄清楚这一点。 我想知道是否TypeError
是由第二个AJAX调用(或osmtogeojson.js
)引起的?
通过提醒它,我确信我的第一个成功函数中的数据不为空。
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
}
});
}
});
}
}
这是浏览器控制台输出的内容:
TypeError:e.elements未定义
[了解更多信息] osmtogeojson.js:4:2503
n http:// localhost:8000 / static / js / osmtogeojson.js:4:2503
ühttp:// localhost:8000 / static / js / osmtogeojson.js:4:14818
成功http:// localhost:8000 /:235:36
我是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
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
链接地址: http://www.djcxy.com/p/28659.html