2011-11-02 3 views
-3

j'ai une fonction:comment vérifier si la fonction est appelée?

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

Mais comment puis-je vérifier que son être appelé? Je veux afficher une boîte d'alerte.

Des idées?

+5

Que voulez-vous dire « vérifier que son être appelé »? Et qu'avez-vous essayé? –

+1

Eh bien, supprimez ces deux barres obliques, '//', au début de votre code. Votre 'alerte' désirée apparaîtra .. EDIT: Hmm ..? Quelqu'un a upvoted cette question? –

+2

Décommenter '// alert ('VariantID =' + VariantID);'? – Matt

Répondre

3

Il suffit de mettre un peu de connexion à l'intérieur et vérifiez votre console?

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

ou si vous ne disposez pas d'un navigateur avec une console, vous pouvez toujours utiliser un alert

alert("getPricing just got called"); 
Questions connexes