Ajax Alert Box Example - Jquery

How to alert ajax requested data?

Snippet Code


  
Rate this page :
  [ 0 votes]

Ajax alert box is used to specify a function when the ajax request is successfully completed. Sample code to create an alert box when ajax request is success using jquery is given below.

<script src='http://code.jquery.com/jquery-2.1.0.min.js'></script> <script> function checkalert(name) { $.ajax({ url: 'test.php', type: 'post', data: {'name' : name}, success: function(data) { alert(data); } }); } </script> <input type='button' onclick='checkalert("Hscripts")' value='Click Here'> test.php: ----------- <?php error_reporting(0); $id = $_POST[name]; echo "Your name is: ".$id; ?>

Tags


Ask Questions

Ask Question