views:

139

answers:

2

I would like to create views, similar to MVC, whereas I can plug HTML into a DIV shadow box that is not originally loaded with the page. The site would need to retrieve the markup via an ajax call upon request. I can invision it being possible retrieving direct html from a data source, but I would like to design the site to be able to contain a folder, with essentially, views that are stored as a physical medium. Is it possbile to retrieve a physical page using ajax and plug that into a target div?

+1  A: 

Not quite sure if that is what you mean, but maybe the load function can help you:

$("#myDiv").load("url/to/ressource.html");

You can also add a selector to the url, to get only parts of the loaded page

$("#myDiv").load("url/to/ressource.html body");
harpax
Would it be possible to load a specific div from the url/to/resource page? Something such as $("#myDiv")'.load("url/to/resource/").Div1?
George
yes .. the second example is like that: $("#myDiv").load("url/to/ressource.html #specificDiv");
harpax
A: 

If you're asking the question conceptually, yes, you can. It would be best to retrieve only the body of the page without the html head section.

However, Javascript is not secure. Even with SSL, it can be monkeyed with on the client side, so depending on what you're building, remember that you may need to do server side validation and such.

Dan Sorensen