2011-11-02 75 views
-3

我有一个函数:如何检查函数是否被调用?

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'); 
} 

但我怎么检查其被称为?我想显示一个警告框。

任何想法?

+5

你是什么意思“检查,其被称为”?你有什么尝试? –

+1

好的,在你的代码开始处删除这两个斜线,'/ /'。你想要的'alert'会出现..编辑:嗯..?有人提出这个问题? –

+2

取消注释// //提醒('VariantID ='+ VariantID);'? – Matt

回答

3

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

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

,或者如果你没有一个浏览器控制台,你总是可以使用alert

alert("getPricing just got called");