jQuery Ajax raising TypeError

I'm having quite a hard time to figure this out. I would like to know if TypeError is caused by the second AJAX call (or the osmtogeojson.js )?

I made sure that my data in the first success function is not null by alerting it.

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
                }
            });
          }
        });
    }
}

This is the what the browser console outputs:

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

链接地址: http://www.djcxy.com/p/28660.html

上一篇: 如何为某些HTML标记存储任意数据

下一篇: 引发TypeError的jQuery Ajax