Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-08-2009
Member
 
Join Date: Oct 2008
Posts: 35
Loading content of a text .txt file using jQuery

Hello,

I need to know the correct way for uploading the content of a text (.txt) file using jQuery. Any sample example would also help me. Can anyone point me in the right direction please?

Thanks in advance.
Reply With Quote
  #2  
Old 04-08-2009
Member
 
Join Date: May 2008
Posts: 37
Re: Loading content of a text .txt file using jQuery

Loading content dynamically with jQuery

We will load content in 2 ways: locating each section in the same file (sections.html) and loading all the content from an external file (external.html).

Code:
<div id="section_home">  
     <h2>Home</h2>  
     <p>  
          <a href="">dummy</a> Here is some text.
     </p>  
     <p>  
          <a href="">typesetting industry</a>.  Here is some text.
     </p>  
 </div>  
   
 <div id="section_news">  
     <h2>News</h2>  
     <p>  
         We have released our forums, <a href="http://forums.yensdesign.com">check it out</a>!  
     </p>  
 </div>  
   
 <div id="section_interviews">  
     <h2>Interviews section</h2>  
     <p>  
         We have interviewed Victor Espigares, creator of <a href="http://www.visualizeus.com">visualizeus</a>!  
     </p>  
 </div>
Here you have external.html:

Code:
   1. <div id="section_external">  
   2. <h2>External content!</h2>  
   3. In this case we are loading the External section from other external file, instead of use jQuery selectors in the sections.html file.</div>
Reply With Quote
  #3  
Old 04-08-2009
Member
 
Join Date: May 2008
Posts: 32
Re: Loading content of a text .txt file using jQuery

jQuery Load Content

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.

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.

jQuery code in the page

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

Code:
function contentDisp()
{
$.ajax({
url : "textContent.php",
success : function (data) {
$("#contentArea").html(data);
}
});
}
Reply With Quote
  #4  
Old 04-08-2009
Member
 
Join Date: Oct 2008
Posts: 35
Re: Loading content of a text .txt file using jQuery

Hey guys thanks for providing exactly what i needed & that too so fast.

Thanks again.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Loading content of a text .txt file using jQuery"
Thread Thread Starter Forum Replies Last Post
How to display content of cell in a text box Excel 2003 VBA !Jumala! MS Office Support 2 21-02-2012 02:03 PM
Need to use jQuery in content process of Mozilla Firefox Gowravaram Technology & Internet 5 02-02-2012 05:22 AM
Getting ?An error occurred loading this content. Try again Later" in apple TV 2G Akono Monitor & Video Cards 10 06-01-2012 10:23 PM
Facebook for android stopped loading content? Roasted Portable Devices 6 03-06-2010 10:02 AM
ie press ok to continue loading the content on the page Ashton5 Windows Software 3 09-06-2009 07:53 PM


All times are GMT +5.5. The time now is 05:25 AM.