Jquery Ajax Basic Example - Jquery

How to use ajax in jquery?

Snippet Code

Rate this page :
  [ 1 votes]

This simple jquery ajax code sends a request and get response from ajaxphppage.php. Here we have send a request data(name=hscripts.com) via post method to ajaxphppage.php. The response will be displayed in alert message.

<input type='button' onclick="ajaxa()" value="Check"> <script type='text/javascript' src='./jquery.js'></script> <script type='text/javascript'> function ajaxa() { $.ajax({ url: 'ajaxphppage.php', type: 'POST', data: 'name=hscripts.com', success: function(data) { //called when successful alert(data) }, error: function(e) { //called when there is an error //console.log(e.message); alert(e.message) } }); } </script>


Ask Questions

Ask Question