简体   繁体   English

未捕获的TypeError:无法调用未定义的方法'indexOf'

[英]Uncaught TypeError: Cannot call method 'indexOf' of undefined

I have below two javascripts on a page HTML Header in my oracle apex application. 我的oracle apex应用程序中的页面HTML Header javascripts有以下两个javascripts

<script type="text/javascript">
function createEventListeners3(pThis)
{

var mainRow = "f04_"+pThis.id.substr(pThis.id.indexOf('_')+1);
$("#" + mainRow).change(function(){
var that = this;
var vRow = "f06_"+pThis.id.substr(pThis.id.indexOf('_')+1);
$.post("wwv_flow.show", 
       {p_request      : "APPLICATION_PROCESS=GET_AMOUNT",
        p_flow_id      : $v("pFlowId"),
        p_flow_step_id : $v("pFlowStepId"),
        p_instance     : $v("pInstance"),
        x01            : $(this).val()
        },
        function(data){ 
            if ($("#" + vRow).val() == ''){
                $("#" + vRow).val(data);
            }
        },
        "text"
      );
});

}
</script>

and i'm calling above javascript from autocomplete select event in here. 我在这里从autocomplete select event中调用上述javascript

<script type="text/javascript">
function createEventListeners()
{

$(function(){
 /* Set autocomplete */
 $('input[name="f04"]').autocomplete({
  source:function(req,res){

   /* Parameters for jQuery ajax */
   var opt={
    url:"wwv_flow.show",
    dataType:"json",
    traditional:true,
    cache:false,
    type:"POST",
    data:{
     p_flow_id:$v("pFlowId"),
     p_flow_step_id:$v("pFlowStepId"),
     p_instance:$v("pInstance"),
     p_request:"APPLICATION_PROCESS=GET_DESCRIPTION",
     x01:req.term
    },
    success:function(jsonData){
     res(
      $.map(jsonData.row,function(jsonRow){
       return{
        label:jsonRow.RET,
        value:jsonRow.DIS
       };
      })
     );
    }
   };
   /* Call Ajax to get list */
   $.ajax(opt);
  },
  focus:function(event,ui){
   /* Prevent value change when list get focus */
//   return false;
event.preventDefault();
  },

  select: function (event, ui) {

    createEventListeners3(this.id);
}

 });
});

return;
}
</script>

but i'm getting below error. 但我越来越错误。

Uncaught TypeError: Cannot call method 'indexOf' of undefined

How could i solve this ? 我该如何解决?

You can already passing id not the object to function createEventListeners3 . 您已经可以将id而不是对象传递给函数createEventListeners3 Pass the object using this instead of this.id 使用this而不是this.id传递对象

Change 更改

createEventListeners3(this.id);

To

createEventListeners3(this);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “未捕获的TypeError:当选择jqgrid行时,无法调用未定义的方法&#39;indexOf&#39; - “Uncaught TypeError: Cannot call method 'indexOf' of undefined” when selected jqgrid row Uncaught TypeError:无法调用未定义的方法“ then” - Uncaught TypeError: Cannot call method 'then' of undefined 未捕获的TypeError:无法调用未定义的方法“ toLowerCase” - Uncaught TypeError: Cannot call method 'toLowerCase' of undefined 未捕获的TypeError:无法调用未定义的方法&#39;addEventListener&#39; - Uncaught TypeError: Cannot call method 'addEventListener' of undefined uncaught typeError:无法调用未定义的方法“ extend” - uncaught typeError: cannot call method 'extend' of undefined 未捕获的TypeError:无法调用未定义的方法'toLowerCase' - Uncaught TypeError: Cannot call method 'toLowerCase' of undefined 未捕获的TypeError:无法调用未定义的方法&#39;replace&#39; - Uncaught TypeError: Cannot call method 'replace' of undefined 未捕获的类型错误:无法调用未定义的方法“html” - Uncaught TypeError: Cannot call method 'html' of undefined 未捕获的TypeError:无法调用未定义的方法“ getLayer” - Uncaught TypeError: Cannot call method 'getLayer' of undefined 未捕获的TypeError:无法调用未定义的方法&#39;Pa&#39; - Uncaught TypeError: Cannot call method 'Pa' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM