Hi, Welcome to Just Answer!
Either the wires at the door jam are pinched or the switch needs to be replaced. Look around the wiring harness that goes from the door to the rest of the car and see if it looks damaged at all. if it does, you may need to use a multi-meter and check each individual wire to find the damaged one.
If the wiring harness looks OK, then odds are the switch just needs to be replaced to fix the problem.
Reference Link: How to Use a Multi-meter