叫不实现接口的对象上HTMLInputElement

叫不实现接口的对象上HTMLInputElement

本文介绍了类型错误:“升压”叫不实现接口的对象上HTMLInputElement的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个错误在使用AJAX的:

 类型错误:升压叫不实现接口HTMLInputElement的对象。


        ......完整的,[C,P]), -  x.active || x.event.trigger(ajaxStop)))}回复C}的getJSON:functi ...
 

下面是我的code部位,我使用它:

 <脚本SRC =HTTP://$c$c.jquery.com/jquery-1.10.1.min.js>< / SCRIPT>
 

,这是我的javascript code在我面前定义他们复选框的作品:

 函数反馈(){
    VAR盒= document.getElementsByClassName('盒子');
    对于(VAR J = 0; J< boxes.length; J ++){
        如果(盒[J] .checked){
            //分配(1);
            分配= 1;
        }
        其他 {
            分配= 0;
            //分配(0);
        }
        VAR的wordID = document.getElementsByClassName('的wordID')[J]。
        $阿贾克斯({
            网址:assigner.php
            键入:POST,
            数据:{的wordID:的wordID,分配:分配}
        })。完成(功能(E){
          / *警告(这个词被保存+ E); * /
        });
    }
}
 

我试过,但它不工作。它没有任何错误。

  VAR为newValue ='';
$('输入[名称=的wordID \\ \\]]')。每个(函数(指数,元素){
    为newValue = newvalue中+ THIS.VALUE +',';
});
$阿贾克斯({
    网址:assigner.php
    键入:POST,
    数据:{的wordID:newvalue中,分配:分配}
})。完成(功能(E){
    / *警告(这个词被保存+ E); * /
});
 

解决方案

$。阿贾克斯不期望类型的DOMElement HTMLInputElement 中要传递到数据的对象。尝试只是给它的字段的值改为:

  VAR的wordID = $('的wordID')VAL()。
$阿贾克斯({
    网址:assigner.php
    键入:POST,
    数据:{的wordID:的wordID,分配:分配}
})。完成(功能(E){
    / *警告(这个词被保存+ E); * /
});
 

I have an error in using 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 parts of my code that I use it:

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

and it is my javascript code that works on checkboxes that 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. it doesn't have any error.

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 );*/
});
解决方案

$.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 );*/
});

这篇关于类型错误:“升压”叫不实现接口的对象上HTMLInputElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 00:04