0

I've got an ajax call via jquery that executes without error until I get to the callback. The content returned looks like this:

{"UPSELLABLE":true,"OFFERTEXT":"p47r.cfm"}

Simply doing alert(upselldata); will alert the data above. But if I try access variable upselldata like a javascript object( I thought jquery did the eval work for me already ), the variables are undefined. See code below:

        $.ajax({
         type: "POST",
         datatype: "json",
         data: "ProductID=1",
         url: '/templates/public/upsell_available.cfm',
         success: function(upselldata) {               
          alert(upselldata.UPSELLABLE); // upselldata.upsellable is undefined!?!?!
         }
        });

1 Answer 1

2

Use "dataType" not "datatype". Javascript is case-sensitive, therefore, jQuery is ignoring your setting.

Note that jQuery can auto-detect the type of data if you set the the headers properly in the response (I assume you are sending it back as text).

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

1 Comment

+1 I never knew the basic jQuery call returned a JavaScript Object

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.