0

I'm wanting to pass information relating to orders into my template via an ajax call. The problem is that that I've got more than two values that I want to pass in.

Key: Email address

Values that pertain to each key that I want to pass in:

  • Invoice Date

  • Name

  • Phone number

I'm wondering what the best way to do this is. Does the dictionary value need to be a list?

eg.

order_dict[order.email] = ['order.invoice_date', 'order.name', 'order.phone']

If the dictionary value does need to be a list, how would I iterate over it in my template?

Thanks for your help!

Jason Howard
  • 1,464
  • 1
  • 14
  • 43
  • You do not need to return a list to the template, you can return any valid JSON structure – Chris Jan 13 '20 at 01:25
  • What do you mean by "iterating over it in my template"? You mean looping through your JSON object in javascript? – Chris Jan 13 '20 at 01:26
  • Yes, looping through the list within the template. – Jason Howard Jan 13 '20 at 02:33
  • Looping through key value pairs can be found [here](https://stackoverflow.com/questions/684672/how-do-i-loop-through-or-enumerate-a-javascript-object) – Chris Jan 13 '20 at 04:45
  • Looping over an array is described in this SO [post](https://stackoverflow.com/questions/3010840/loop-through-an-array-in-javascript) – Chris Jan 13 '20 at 04:47

0 Answers0