I'm trying to design (what to me is) a complex function and I need to know if I am doing things correctly before I go any further. What I've got is here:
http://jsfiddle.net/mbielski/MjbhU/
The way things should work is that a new customer is created, and then:
if the address is not blank
add it to the customer with another HTTP Post
if the phone number is not blank
add it to the customer with another HTTP Post
if the email address is not blank
add it to the customer with another HTTP Post
Once all HTTP posts are done
Make another HTTP Post
Exit Function
Each of the three sub-items require that adding a customer be completed successfully, but none of them depend upon the others to do what they need to do. Lastly, I need to wait until any and all of the inner HTTP posts are complete before moving on. I don't think what I have constructed will function the way I need it to, but I don't know how it needs to be changed. Any help would be greatly appreciated.