首先我想说的是,我尝试过很多codeS和插件,但没有为我工作。我只是试图让按钮后退和前进在浏览器中再次调用AJAX称为页,使他们出现在按钮点击后。我希望你能,我不是开发商:)
请帮我的家伙,这些都是工作日内在这个非常时刻...:)
的处理程序:
<李>< A HREF =#级=CENI>примерницени< / A>< /李> <李>< A HREF =#级=karieri>кариери< / A>< /李>
JavaScript的:
$('。CENI)。点击(函数(){ $阿贾克斯({ 网址:'页/ ceni.php', 成功:函数(响应){ $(#页)HTML(响应); } }); }); $('。karieri)。点击(函数(){ $阿贾克斯({ 网址:'页/ karieri.php', 成功:函数(响应){ $(#页)HTML(响应); } }); });解决方案
最常用的方法是使用一个插件监测hashchange事件,并再次请求AJAX页面。
<李><一类=CENI的href =#CENI>примерницени< / A>< /李> <李><一类=karieri的href =#karieri>кариери< / A>< /李>
设置散列变化处理程序:
的jQuery(窗口).bind('hashchange',函数(){ 变种pageHash = location.hash.substr(1); 如果('CENI | karieri |'.indexOf(pageHash +'|')> = 0){ 。jQuery的(#页)负载(pageHash +.PHP); } });
加载内容转换成通过jQuery一个元素被记录在 api.jquery/load/ 1,并且从根本上与使用jQuery.ajax做出该请求。
作为一种替代方法,您可以使用HTML5历史API文档的 html5demos/history - 它可以让你保持在地址栏看整齐,不得散列
如果您需要支持IE7及以下,使用polyfill的hashchange事件,如 HTTP ://benalman/projects/jquery-hashchange-plugin/
First thing i want to say is that i tried many codes and plugins, but nothing work for me. I am trying only to make the buttons "back" and "forward" in the browser to call again the AJAX called pages so they appear after the buttons are clicked. I hope you get that i am NOT developer :).
Please help me guys, these are days of work in this very moment...:)
The handlers:
<li><a href="#" class="ceni">примерни цени</a></li> <li><a href="#" class="karieri">кариери</a></li>The javascript:
$('.ceni').click(function(){ $.ajax({ url: 'pages/ceni.php', success: function(response) { $("#pages").html(response); } }); }); $('.karieri').click(function(){ $.ajax({ url: 'pages/karieri.php', success: function(response) { $("#pages").html(response); } }); });解决方案
The most common method is by using a plugin for monitoring the hashchange event and re-requesting the ajax page.
<li><a class="ceni" href="#ceni">примерни цени</a></li> <li><a class="karieri" href="#karieri">кариери</a></li>Set up the hash change handlers:
jQuery(window).bind('hashchange', function() { var pageHash = location.hash.substr(1); if('ceni|karieri|'.indexOf(pageHash + '|') >= 0) { jQuery("#pages").load(pageHash + '.php'); } });Loading content into an element via jQuery is documented at api.jquery/load/ and is fundamentally the same as using jQuery.ajax to make the request.
As an alternative, you can use the HTML5 history API documented at html5demos/history - which allows you to keep the address bar looking tidy without the hashes.
If you need to support IE7 and below, use a polyfill for the hashchange event such as benalman/projects/jquery-hashchange-plugin/
更多推荐
如何使AJAX称为页面重新加载在浏览器
发布评论