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

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

1、错误描述

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

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


2、错误原因

$.ajax({
      type:"post",
      url:"/user/queryUserInfo",
      dataType:"json",
      data:{
          "userId":$("#userID").val(),
          "num":num,
          "type":$("#type").val()
      },
      success:function(resp){

      }
});

    由于num未定义,导致查询请求出现错误


3、解决办法

var num = 0;
if($("#type").val() == "1")
{
     num = $("#num").val();
}
else
{
     num = 0;
}

$.ajax({
      type:"post",
      url:"/user/queryUserInfo",
      dataType:"json",
      data:{
          "userId":$("#userID").val(),
          "num":num,
          "type":$("#type").val()
      },
      success:function(resp){

      }
});

     在使用num前,先对其进行初始化并赋值,防止未初始化导致出错


版权声明:本文为博主原创文章,未经博主允许不得转载。