简体   繁体   English

ajax调用函数未定义错误

[英]ajax call function is not defined error

I'm using jquery's ajax function and am getting error: 我正在使用jquery的ajax函数,并且出现错误:

'getQty is not defined' “未定义getQty”

Where is my mistake? 我的错误在哪里?

jQuery: jQuery的:

function getQty()
{
  var dataString = "itemId=" +$(".itemId").val();
  $.ajax({
    type: "GET",
    url: "getQty.php",
    data: dataString,
    success:function(data)
    {
      $(".qty").val(data);
    }
  });
}

HTML: HTML:

 <a href="screen.php?itemId={$itemArray[sec].itemId}" class="btn itemId" name="itemId" onClick="getorder();">{$itemArray[sec].itemNm}</a>

最佳做法是

$('#myLink').click(function(){  getQty(); return false; });

You're calling the wrong function in the HTML: 您在HTML中调用了错误的函数:

onClick="getorder();"

should be: 应该:

onClick="getQty();"

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM