Jump to content

Embedding Html From An External Document Without Php?


therschbach

Recommended Posts

I've been doing some reading and it seems that I need to redo my website because using tables is limiting my functionality. I'm attempting to learn CSS but there's something that I want to do before I continue. I'm sure it's so incredibly simple but I'm teaching myself so there are plenty of gaps in my knowledge.I'd like to be able to click on a menu button and cause the content of a text file to dump into the main area of the site without having to reload the entire page or leave the index....basically giving me the functionality of using frames. I've used php includes and still will use them to load other areas, but I don't want to have to resend the entire page to the browser. Can anyone point me in the right direction or am I not even on the right track?I'm also just learning javascript and php too so be gentle! :)

Link to comment
Share on other sites

  • 2 weeks later...

Ok, I looked into ajax and it seems that by definition, I can only import XML filetypes. That's ok because I've since gone through the XML tutorial as well, but now my question is how do I insert an HTML document such as...<p>Hello!</p><img src="my picture" /><p>More text here.....</p>...into an xml file? It seems that having html tags would be illegal inside XML because they are formatted just like XML.

Link to comment
Share on other sites

Not true. Your server can send you anything, including (especially) HTML scraps, which you can insert directly (no reformatting) into some element's innerHTML. Another common technique is to send JSON strings (basically plain text that can be evaluated as javascript arrays and objects).

Link to comment
Share on other sites

Ok, so let me be sure I understand. I can use AJAX to import a text file containing html code (without the html and body tags, etc) and I don't have to use XML? I can just import a file that contains only this:

<p>Hello!</p><img src="my picture" /><p>More text here.....</p>

Link to comment
Share on other sites

Correct.FYI, you can enclose XML that is not to be parsed (or any character data that needs to be read literally) within another XML document by using the CDATA construct, e.g.

<snippets>	<snippet>		<![CDATA[			<p>Hello!</p>			<p><img src="my picture" /></p>			<p>More text here.....</p>		]]>	</snippet></snippets>

Link to comment
Share on other sites

Ok, cool! Hey thanks a bunch guys. This pretty much takes down the barriers I had to be able to finish my site. Now I just have to put in the time to write it all.Btw, does anyone have any text editor recommendations? I'd been using notepad, then "upgraded" to a program called PSPad but I'm not sure I like it.

Link to comment
Share on other sites

Personally i use Dreamweaver, But each to their own i once used "crimson editor" which was fairly light and done the trick before i became a dreamweaver user.Tried notepad++ Theirs a whole range of programs which are similar just have a look around.maybe this link will serve you well for a starting place http://en.wikipedia.org/wiki/Source_code_editor

Link to comment
Share on other sites

Btw, does anyone have any text editor recommendations? I'd been using notepad, then "upgraded" to a program called PSPad but I'm not sure I like it.
We have a whole thread on that. It's long, so I recommend starting hereabouts: http://w3schools.invisionzone.com/index.ph...=760&st=260A lot of newbies on the thread have newbie opinions, which can be silly sometimes, so I suggest you compare the recommendations with the number of posts the person has made on this forum. Anyone who's posted more than 500 times or so probably knows what's going on. And follow the thread to the end, because things get improved, changed, replaced.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...