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
596 views
in Technique[技术] by (71.8m points)

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

I have an error in my use of AJAX:

TypeError: 'stepUp' called on an object that does not implement interface HTMLInputElement....plete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:functi...

Here is the parts of my code where I use it:

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

It is my javascript code that works on checkboxes where I defined them before:

function feedback() {
    var boxes = document.getElementsByClassName('box');
    for (var j = 0; j < boxes.length; j++) {
        if (boxes[j].checked) {
            //assign(1);
            assign = 1;
        } else {
            assign = 0;
            //assign(0);
        }
        var wordid = document.getElementsByClassName('wordId')[j];
        $.ajax({
            url: "assigner.php",
            type: "POST",
            data: {
                wordid: wordid,
                assign: assign
            }
        }).done(function(e) {
            /*alert( "word was saved" + e );*/
        });
    }
}

I tried this but it doesn't work and it doesn't give me any errors.

var newvalue = '';
$('input[name=wordid\[\]]').each(function(index, element) {
    newvalue = newvalue + this.value + ',';
});
$.ajax({
    url: "assigner.php",
    type: "POST",
    data: {
        wordid: newvalue,
        assign: assign
    }
}).done(function(e) {
    /*alert( "word was saved" + e );*/
});
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

$.ajax is not expecting a DOMElement of type HTMLInputElement in the object you are passing to data. Try just giving it the value of the field instead:

var wordid = $('.wordId').val();
$.ajax({
    url: "assigner.php",
    type: "POST",
    data: { wordid: wordid, assign: assign}
}).done(function( e ) {
    /*alert( "word was saved" + e );*/
});

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

...