I have searched on SO and couldn't find an appropriate answer.
Very simple. I am defining variables via form submission:
var first_name=jQuery("#contact_first_name_1").val();
var last_name=jQuery("#contact_last_name_1").val();
var email=jQuery("#contact_email_1").val();
Then defining the "dataString"
var dataString =
'first_name='+ first_name +
'&last_name=' + last_name +
'&email=' + email +
But having a problem if a form field is left empty, it returns "undefined".
I tried this, but it is not working:
if (last_name != undefined) {
'&last_name=' + last_name +
}
I know this is simple, but simply can't get the right code to work on this example. Thanks!