0

I have code like this:

var form_data = {
        services: $("input[id^='campaign_cbx_']:checked").serialize(),

                };

And if no campaign_cbx_something checkbox is checked i would like to have an epmty array, but in php I have array with 0 index and empty string value. How to resolve it?

1 Answer 1

2

Not recommendable, but how about

var data = $("input[id^='campaign_cbx_']:checked").serialize();
var form_data = {
   services: data?data:"campaign_cbx[0]=" 
};

I strongly suggest your PHP can handle empty data

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.