views:

780

answers:

3

Is it possible to load an entire page head and all with ajax/jquery? Without a reload. I want to be able to slide a page in iphone like. I need to load the head as it contains javascript specific to each page.

Thanks.

A: 

See this question.

kgiannakakis
+1  A: 
$("#tag_id").load("page.html");

This will load page.html into a DIV tag or any other tag with the ID tag_id.

Roland
+2  A: 

One Solution is to have a div that takes up the entire width and height of the page with a unique id and then use jQuery to make an ajax request that returns javascript to manipulate that div like so:

say you had a link with an id of "link"



$(document).ready(function(){
    $("#link").click(function(){
     $.post("newContent.html", key-value-pairs, call-back-function, "script")
     return false
    });

});

this code bit intercepts the links default action and instead fires of an ajax post request. When the request comes back the return is evaluated as javascript as specified by the last parameter of the "post" function.

this way you can have the server return jquery or any javascript code to do whatever you want with the page without having to reload the head or any body information that is going to remain the same.

shit a birck
This looks cool, I will try this THX