Jquery Ajax Success Example - Jquery

How to create alert if ajax call is success in jquery ajax?

Snippet Code


  
Rate this page :
  [ 0 votes]

Jquery ajax success code allows you to create success alert message when the data passed is true. The simple jquery code to create a success alert message is given below.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script type='text/javascript'> function ajax_call() { var test = $.ajax({ url : 'ajax-demo.php', type: 'POST', data: {name:'hscripts'}, success: function(data) { alert(data); } }); } </script> <input type='button' value='Click Here!' onclick='ajax_call()'> ajax-demo.php: <?php $username = $_POST["name"]; if(isset($username)) { echo "Welcome to ".$username; } ?>

Tags


Ask Questions

Ask Question