how to enable ajax on submitting of contact form 7?

Not sure about ajax, but you could use a custom DOM event to run some javascript…

From the “contact form 7” documentation:

The simplest way is utilizing Contact Form 7’s custom DOM event to run JavaScript. The following is an example of script that redirects you to another URL when the wpcf7mailsent event occurs:

<script>
  document.addEventListener( 'wpcf7mailsent', function( event ) {
    location = 'http://example.com/';
  }, false );
</script>

Redirecting to Another URL After Submissions