Ampicillin is an antibiotic belonging to the group of beta-lactam antibiotics. These will kill Gram-negative bacteria to which E.coli and Salmonella belong. The antibiotic prevents the formation of peptidoglycan, an essential building block of the cell membrane. So the antibiotic prevents growth of cells. Unfortunately, I don't have my micro books with me, but I'll try.
Bacteria have a unique compound in their cell walls called peptidoglycan.
Penicillin prevents the crosslinking of the sugars by breaking the tetrapeptides. Some bacteria have adapted to this situation by having an enzyme called beta-lactamase that breaks the structure of the antibiotic open rendering it ineffective. Argonne National Laboratory, Division of Educational Programs, Harold Myron, Ph.D., Division Director.