Reputation: 2645
This is probably pretty simple, but I can't figure out how to do it: I have this code:
$.post("/admin/contract", {
'mark_paid' : true,
'id' : id
},
In pseudo code, how can I do this:
$.post("/admin/contract", {
'mark_paid' : true,
'id' : id,
if(is_set(dont_email)) {print 'dont_email' : true}
},
Upvotes: 1
Views: 142
Reputation: 21784
I'm not sure I understand your question correctly. Is dont_email a variable? Are you checking the existence of dont_email?
var myDontEmail = (typeof(dont_email) != "undefined");
$.post("/admin/contract", {
'mark_paid' : true,
'id' : id,
'dont_email': myDontEmail
},
Upvotes: 0
Reputation: 27765
Try this:
$.post("/admin/contract", {
'mark_paid' : true,
'id' : id,
'dont_email': (is_set(dont_email))?true:false
},
Upvotes: 0
Reputation: 105888
How I'd do it.
$.post("/admin/contract", {
'mark_paid' : true,
'id' : id,
'dont_email' : ( 'undefined' != typeof dont_email )
},
Upvotes: 7
Reputation: 14415
var details = {
'mark_paid' : true,
'id' : id,
}
if(is_set(dont_email)) {
details.dont_email = true;
}
$.post("/admin/contract", details);
untested...
Upvotes: 1
Reputation: 18775
I'll give it a try :
$.post("/admin/contract", {
'mark_paid' : true,
'id' : id,
'dont_email' : is_set(dont_email) ? true : undefined
},
Upvotes: 2