SarmenB
SarmenB

Reputation: 25

variables showing as undefined in firebug when they are defined

here is my site http://iadprint.com/products?product=Business%20Card

when i select a value for quantity a price is supposed to show in the pricing div on the top right. this used to work but for some reason today in firebug under dom i can see that a few variables show undefined. when i do the ajax call iadprint.com/ajax.php?id=1 the data shows correctly and the variables in the js are all defined. what can be wrong? here are the variables that i am seeing undefined.

woCoating_price
woColor_price
woDesign_price
woJob_Name_price
woPDF_Proof_price
woQuantity_price
woRound_Corners_price
woTurnaround_price

Upvotes: 1

Views: 642

Answers (1)

user113716
user113716

Reputation: 322462

I replaced your $.get() call with a full $.ajax() call that includes an error: callback.

The result is that you're getting a parse error because your JSON response is invalid.

"parsererror" "Invalid JSON: {"price":"15.00"}<br/>"

You need to get rid of that <br/> tag.

If this isn't it, then you'll need to provide specific detail on how to reproduce the problem, and in which part of your code you expect to see a defined value.


EDIT: Here's the change handler I used after removing yours:

$("#Quantity").change(function () {
    hash = $("#Quantity").val();
    console.log('hash',hash);

    $.ajax({
        url:"ajax.php",
        data: { id: hash },
        dataType:'json',
        success:function (out,b,c) {
            woQuantity_price = out.price;
            displayPrice();
            console.log(out,woQuantity_price,b,c);
        },
        error:function(a,b,c){
            console.log('error:',a,b,c);
        }
    });
});

Upvotes: 1

Related Questions