Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

javascript - TypeError: stepUp called on an object that does not implement interface HTMLInputElement

I have this code

<a data-remote="true" data-box_no="1" class="find_or_add_horse" href="#">Find/Add Horse</a>

And I do ajax call when I click one the link

$(document).on('click', '.find_or_add_horse', function () {
        var search_term = $(this).parents('.sub-middle-column').find('.search_horse');
        var box_no = $(this).data('box_no');


        $.ajax({
            url: "/startup_wizard/find_horse",
            dataType: 'script',
            type: 'GET',
            data: { box_no: box_no, search_term: search_term}
        });
        return false;


    });

But when I click on the link I get this error "TypeError: 'stepUp' called on an object that does not implement interface HTMLInputElement" when I remove this code from ajax call

data: { box_no: box_no, search_term: search_term}

my code just work fine. Why this is happening and how to fix this? How can I send the data?

question from:https://stackoverflow.com/questions/22962933/typeerror-stepup-called-on-an-object-that-does-not-implement-interface-htmlinpu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If search_term is an input field you might want to get its value.

var search_term = $(this).parents('.sub-middle-column').find('.search_horse').val();

Right now you are referencing a jQuery Object containing a HTMLDom-Element but I think what you want is the string inside the search input element.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...