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

1、错误描述




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前,先对其进行初始化并赋值,防止未初始化导致出错


原文地址:https://www.cnblogs.com/hzcya1995/p/13314440.html