如何检查是否正在调用函数?

时间:2011-11-02 15:56:27

标签: javascript

我有一个功能:

function getPricing(ProductID,VariantID)
{
    //alert('VariantID=' + VariantID);
    if(ProductID == undefined || VariantID == undefined)
    {
        return;
    }

    var ChosenSize = "";
    //var ChosenSizeList = document.getElementById('Size');
    var ChosenSizeList = document.getElementById('AddToCartForm_' + ProductID + '_' + VariantID).Size;
    if(ChosenSizeList != undefined)
    {
        ChosenSize = ChosenSizeList.options[ChosenSizeList.selectedIndex].text;
    }

    var ChosenColor = "";
    //var ChosenColorList = document.getElementById('Color');
    var ChosenColorList = document.getElementById('AddToCartForm_' + ProductID + '_' + VariantID).Color
    if(ChosenColorList != undefined)
    {
        ChosenColor = ChosenColorList.options[ChosenColorList.selectedIndex].text;
    }

    var url = "ajaxPricing.aspx?ProductID=" + ProductID + "&VariantID=" + VariantID + "&size=" + escape(ChosenSize) + "&color=" + escape(ChosenColor);

    //alert("Ajax Url=" + url);
    makeHttpRequest(url,undefined,'pricing');
}

但我怎么检查它的被叫?我想显示一个警告框。

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

只需在其中放入一些日志并检查您的控制台?

console.log("getPricing just got called with", arguments);

或者如果您没有带控制台的浏览器,您可以随时使用alert

alert("getPricing just got called");
相关问题