Switch to full style
JQuery Examples
Post a reply

Load file and update content using AJAX and JQuery

Tue Jan 01, 2013 3:27 pm

Code:

<html>
<
head>
<
title>Get File using AJAX under JQuery</title>
<!--
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
 Note you can download the JQuery package instead of using Google version. --> 
<script src="jquery-1.8.3.js"></script>
<script>
 $(document).ready(function(){
   $("button#b1").click(function(){
  $("div#d1").load("smallTable.html",function(responseTxt,statusTxt,xhr){
    if(statusTxt=="success")
      alert("New content loaded successfully!");
    if(statusTxt=="error")
      alert("Error: "+xhr.status+": status:"+xhr.statusText);
  });
 });
  
});
</script>
 </head>
<body>
<div id="d1"  >This Text is inside the Div</div>
 <br>
<button  id="b1">Load HTML File</button>
  </body>
</html>


smallTable.html:
Code:
<table>
<
tr>
<
td>
Account 1
</td>
<
td>
Account 2
</td>
</
tr>
<
tr>
<
td>
543USD
</td>
<
td>
433USD
</td>
</
tr>
</
table>
 


Related Error you may face :
scripting-language/solution-to-error-status-zero-when-using-ajax-with-jquery-t10684.html



Post a reply
  Related Posts  to : Load file and update content using AJAX and JQuery
 Load Content to Tabs using AJAX and JQuery     -  
 Update table with search box using ajax     -  
 Load tweets using JQuery     -  
 Load RSS feeds and parse it with JQuery     -  
 Change the content of select tag using JQuery     -  
 update an xml file with jaxb     -  
 update an xml file with jaxb and accessing to its elements     -  
 Solution to Error status zero when using Ajax with JQuery     -  
 display the content of text file     -  
 Read XML file content using SAX and writing its as SQL     -  

Topic Tags

JQuery Content