Frameworks| Hibernate| Struts| JSF| JavaFX| Ajax| Spring| DOJO| JDO| iBatis| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
jQuery Load Content 
 

In this section you will learn how to load content of a text file using jQuery and show it on the use browser. This example shows you how to load the content of simple text file and then show on the text box.

 

jQuery Load Content

                         

In this section you will learn how to load content of a text file using jQuery and show it on the use browser. This example shows you how to load the content of simple text file and then show on the text box.

Our jQuery Load Content example will do the following work

  1. Web page is displayed with a button "Load Content" and a blank text box
  2. User clicks on the "Load Content" button.
  3. jQuery loads the context of a text file "testFile.txt" and displays in the text area

After completing this example you will be able to use jQuery to Load the content from server side text file and show it to the user.

Code:

1. HTML Page

Here is the code of "displayContent.html" file

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Show Content</title>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script type="text/javascript"> 
function contentDisp()
{
$.ajax({
url : "textContent.php",
success : function (data) {
$("#contentArea").html(data);
}
});
}

</script> 
</head>
<body>
<table width="100%" border=0>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td width="30%" >&nbsp;</td><td style="color:blue;" width="70%">
Download Content Example</td></tr>

<tr><td>&nbsp;</td><td ><input type="button" value="Click" onClick="
contentDisp();">&nbsp;<span style="color:blue;"></span></td></tr>

<tr><td>&nbsp;</td><td>
<textarea id="contentArea" rows="10" cols="50"></textarea>
</td>
</tr>
</table>
</body>
</html>

 

2. jQuery code in the page

The following jQuery code retrieves the data from server and display in the text area.

function contentDisp()
{
$.ajax({
url : "textContent.php",
success : function (data) {
$("#contentArea").html(data);
}
});
}

3. Content of the text file

Here is the content of the text file:

Welcome to RoseIndia.Net jQuery Tutorials

Learn how you can do a lot of work with small code.

jQuery is here to help us in achieving high result with less coding.

jQuery is great!!!!

4. Program screen shot

Open your browse and type http://localhost/displayContent.html. Your browser should look like:

 

Now click on the "Click" button. The program will fetch the text data from database and display in the text area as shown below:

 

In this example you leaned how to fetch the text data from server and display in the text area.

Try the example online

                         

» View all related tutorials
Related Tags: jquery c query image images tutorial change ria this id with program to ram effect e il it li hang

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

Hello
I want c# file, no need php file(textContent.php ).
Thanking u
Suresh.R

Posted by Suresh.R on Tuesday, 07.29.08 @ 23:57pm | #69838

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.