문제

I am using django + jquery to write a html page, the layout of the page is:

head (divs)
--------------------------
left (divs) | right (divs)

I want to change the whole page (the head divs would be all the same, but the left and right divs would be changed) after I click the head divs(the js would send a post message to the django and get the responsed html).

now I could get the whole new page, but I don't know how to rerender the whole page again? any help would be appriciated!

도움이 되었습니까?

해결책

You can do this with conjunction of jQuery load() and adding a new div to contain the content of the site:

head (divs)
--------------------------
container div
left (divs) | right (divs)
/container div

So you, do something like this.

$('#container').load('ajax/test.html #container');

See the documentation for jQuery load, it let's you loading into specific elements and filter which part of the html to include.

다른 팁

Can't you simply use jQuery.load() ?

$('#left').load('ajax/test.html', function() {
  alert('Load was performed.');
});

There is much ways to do it:

  1. you click and django send via ajax the new content and the browser will display it
  2. you can keep the divs but change some of there content/text etc
  3. use the function load(), check here:enter link description here
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top