开发者

Theoric question on HTML

is it possible via html to recall a HTML file (template) recall it and just change the value of PHP variable. And by the same way, this template position itself (with css) without any change?

Example: You want to display d开发者_JAVA技巧ifferent objects to sell and the template is set graphically (photo + name + price) and you want to put another one just beside it.

If yes, by Javascript? or else?

Thanks


Using jQuery is very easy.

(1) Link your CSS earlier in the main HTML so when your template loaded the css will automatically applied.

(2) Add jQuery script like <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script> or you can download jQuery yourself and use yout own path.

(3) Assume you have <div id="containner"></div> to populate the template later.

(4) When the document load, button click or whenever you want to trigger to load the template simply call $('#containner').load('/path/template.html'); this is jQuery javascript code. the .load() method is an Ajax call to your template file.

(5) Any PHP variables in the template file will be evaluated and will produce html only since at server side.

(6) The returned template will populated in the containner div.


use ajax, the Javascript runs on the client browser can call a server side script and switch page content without refresh the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜