1

Apologies for the lack of knowledge to start with...

We have a page on our website that displays a price depending on the users selection of size width and quantity Unfortunately the dynamic calculator isn't showing the price, even though the script seems to be calculating the price...

Can anyone help me where I am going wrong :-(

When I debug in the console it displays the information correctly but just doesn't show!!!

EDIT:The javascript that should output the price is

    <script>
$(function() {
    $('#inputqty').keyup(function() {
        var inputqty = $('#inputqty').val();
        var sku = $('#selSKU').val();
        $.getJSON('pricecheck.cfc?method=getPrice&returntype=JSON&sku='+sku+'&qty='+inputqty, function(data) {
            $("#divPrice").html(data.displayPrice);
        });
    });

});

    function qtyChanged(){
        var inputqty = $('#inputqty').val();
        var sku = $('#selSKU').val();
        $.getJSON('pricecheck.cfc?method=getPrice&returntype=JSON&sku='+sku+'&qty='+inputqty, function(data) {
            $("#divPrice").html(data.displayPrice);
        });


    };
</script>
16
  • 1
    Please post up the snippets of js that deal with the output. I can see the XHR returning the values but chances are it's not actually being used as intended. Commented Mar 26, 2013 at 11:31
  • 1
    Please post only relevant code on jsfiddle, for example. Its kinda hard to find the issue in all your scripts. Commented Mar 26, 2013 at 11:34
  • 1
    Please don't only link the buggy site, but post the relevant code. Commented Mar 26, 2013 at 11:41
  • Sorry, I will try and find the problem code, I am not sure what part to post but I will look now Commented Mar 26, 2013 at 11:44
  • 1
    Check if the "Secure JSON" option is turned on in ColdFusion Administrator. "//" is the default prefix used when this option is enabled. If you want to keep the security feature enabled, you'll need to modify your JavaScript code to remove the // before processing the JSON. Commented Mar 26, 2013 at 16:47

1 Answer 1

2

Looks like the results of http://www.xxxxxxxx.co.uk/pricecheck.cfc?method=getPrice&returntype=JSON&sku=2947&qty=7contains an error.

//{"displayPrice":"£2.87 excl. VAT<\/strong>
(£3.44 incl VAT)<\/span>"}

Notice the comment (double slash) that prefixes the JSON.

It also looks like $.getJSON will fail silently if the JSON contains a syntax error: Why does $.getJSON silently fail?

Sign up to request clarification or add additional context in comments.

1 Comment

Thankyou for your help, i cannot find the // that is causing the fail though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.