How to post with out refreshing the page

Ajax POST format:

request is post to register.php page.
All the database insert , update query is written there.

connect with jquery library online using–
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>

Method-1:

var myemail = $("#email").val();
var mypass = $("#pass").val();

var datastring = {'email':myemail, 'pass': mypass };

// AJAX METHOS IS CALLED
$.ajax({ 
   url:"register.php", 
   type:"post", 
   data: datastring,
   success:function(data){
      alert (data);
   } 
});
Method-2:

// GETTING THE INPUT FIELD VALUE BY THEIR ID
var myemail = $("#email").val();
var mypass = $("#pass").val();

// POST METHOD  CALL
$.post("register.php",{email:myemail,pass:mypass},function(data){
     
     // ON SUCCESS RETURN DATA FROM POSTED PAGE
     alert(data);
});
Please follow and like us: