having issue with null values in ajax passing data

Viewed 21

I am trying to handle the filter parameters which I am passing them with ajax, but the problem is when an option for a parameter is not selected and it's null, the response will be empty; instead of that i want that null parameter not to be sent at all.

for example when q_cityId is null i dont want q_cityId[0] to be sent:

        $.ajax({
            url: "https://fhzapi.sedevs.com/landing/school-programs/get-fields-and-search",
            type: "GET",
            data: {
                "list": "paginate",
                "perPage": perPage,
                "q_programName": q_programName,
                "q_countryId[0]": q_countryId,
                "q_cityId[0]": q_cityId,
                "page": page
       },.. 

what is the solution?

0 Answers
Related