我在使用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…
这里是我的代码的部分,我使用它:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
这是我的JavaScript代码工作在复选框,我在其中定义它们:
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 );*/ }); } }
我试过这个,但它不工作,它不给我任何错误。
var newvalue = ''; $('input[name=wordid\\[\\]]').each(function(index,element) { newvalue = newvalue + this.value + ','; }); $.ajax({ url: "assigner.PHP",data: { wordid: newvalue,assign: assign } }).done(function(e) { /*alert( "word was saved" + e );*/ });
解决方法
$ .ajax不期望在传递给数据的对象中有一个类型为HTMLInputElement的DOMElement。尝试只是给它的字段的值:
var wordid = $('.wordId').val(); $.ajax({ url: "assigner.PHP",data: { wordid: wordid,assign: assign} }).done(function( e ) { /*alert( "word was saved" + e );*/ });