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.
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.
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).
Here you have 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>
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>
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); } }); }
Hey guys thanks for providing exactly what i needed & that too so fast.
Thanks again.
Bookmarks