Jquery Get Example Ajax - Jquery

How to get contents through jquery ajax?

Snippet Code

Rate this page :
  [ 0 votes]

Jquery code fetch the data passed through ajax request and returns it to ajax- demo.php page. This is a simple jquery code used to get the content. $_GET["name"]; variable is used to get the content from the request page.

<script type='text/javascript'> $(document).ready(function(){ $.ajax({ url: 'ajax-demo.php', type: 'GET', data: 'name=hscripts', success: function(data) { $('#output').html(data); } }); }); </script> <div id='output' align='center'></div> ajax-demo.php <?php $username = $_GET["name"]; if(isset($username)) { echo "Your name is : ".$username; } ?>


Ask Questions

Ask Question