/ Published in: jQuery
Here is a basic example as to how to set up an Ajax request.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!-- jQuery Framework --> <script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" charset="utf-8"> function getData( url ){ $.ajax({ url: url, dataType: "json", encoding:"UTF-8", beforeSend: ajaxStart, success: ajaxSuccess, error: ajaxError, complete: ajaxComplete }); } function ajaxStart( xhrInstance ){ //A. Clear Any Previously Written HTML //B. Show Preloader console.log( "ajaxStart:" ) } function ajaxError( xhrInstance, message, optional ){ console.log( "ajaxError:" ); } function ajaxComplete( xhrInstance, status ){ //A. Remove any preloaders console.log( "ajaxComplete:" ); } function ajaxSuccess( data, status ){ //Write your Parse XML Function parseData( data ); } function parseData( data ){ console.log( "parseData:", data ); } </script> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ getData("http://path/to/xml/or/json/feed"); } </script>