0
$.getJSON("./data/revenue-item-data.php",{val:'val'},function(data){

 $('#totalUnits').val(data[0].SUM(item_qty));
     $('#totalAmounts').val(data[0].SUM(DISTINCT net_total));


 });

Here is array I get for above code:

 [{"SUM(item_qty)":"68","SUM(DISTINCT net_total)":"42753"}]

How to display these 2 values (68 , 42753) in #totalUnits & #totalAmounts.This code does not display any thing.

2 Answers 2

2

You can not call data[0].SUM(item_qty) as it treats SUM as a method. Try this.

data[0]['SUM(DISTINCT net_total)']
Sign up to request clarification or add additional context in comments.

Comments

1
$('#totalUnits').val(data["SUM(item_qty)"]);
$('#totalAmounts').val(data["SUM(DISTINCT net_total)"]);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.