Passing Variable From Ajax to Javascript - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajax

Description

Passing Variable From Ajax to Javascript

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>AJAX JSON Example</title> 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 
  <script>
            $(function(){//from   w ww  .j av a 2  s .c  om
                $.getJSON('ajax.php',function(data){
                    $.each(data,function(index,value){
                        $('body').append('Name: ' + value.name + ' | City: ' + value.city + '<br />');
                    })
                });
            });
        
      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials