I made changes to my code
<html> <body> <form action="test.php" id="subscriber_form" method="post" enctype="multipart/form-data"> <input type="text" id="title" name="title" ><br> <input type="file" id="file" name="file" ><br> <input type="submit" id="submit" value="submit"> </form> <div id="show_subscriber_msg"></div> <script src="js/jquery-1.7.1.min.js"></script> <script> $("form#subscriber_form").submit(function(){ $('#show_subscriber_msg').html('<div class=gen>Submiting..</div>'); e.preventDefault(); var formURL = $(this).attr("action"); var formData = new FormData($(this)[0]); $.ajax({ url: formURL, type: 'POST', data: formData, cache: false, contentType: false, processData: false, async: false, success: function (res) { if(res=='1'){ $('#show_subscriber_msg').html('<div class=gen>Thank you</div>'); } if(res=='5'){ $('#show_subscriber_msg').html('<div class=err>Please enter a valid email address</div>'); } } }); }); </script> </body> </html> My sql table is getting updated and file is uploaded to the directory correctly But it's still redirecting me to test.php. I just want to run my php script i.e test.php in background.