es131245 Posted October 1, 2012 Share Posted October 1, 2012 (edited) As i design idea ive done this to my site function page(url){if(url.substr(0,18)!='http://domain.com'||(url.substr(0,18)=='http://domain.com'&&url.substr(-4,1)=='.')){window.location.href=url;return;}$('#content').fadeTo(500,0);setTimeout(function(){if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();} else{xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');} xmlhttp.onreadystatechange=function() {if(xmlhttp.readyState==4&&(xmlhttp.status==200||xmlhttp.status==404)) {$('#content').html(xmlhttp.responseText); links(); $('#content').fadeTo(500,1);}} xmlhttp.open('GET',url+'?method=ajax',true); xmlhttp.send();},500);}function links(){$('a').each(function(){$(this).unbind('click').click(function(){page(this.href);return false;});});}$(document).ready(function(){links();}); mature of you already have spoted a "key" ?method=ajaxas u already undestud its a php part here if(!isset($_GET['method'])||$_GET['method']!='ajax'){if(isset($CFG['content']['head'])){print($CFG['content']['head']);}}if(isset($CFG['content']['style'])){print(' <style type="text/css">'."\n".$CFG['content']['style'].' </style>'."\n");}if(isset($CFG['content']['body'])){print($CFG['content']['body']);}if(isset($CFG['content']['script'])){print(' <script type="text/javascript">'."\n".$CFG['content']['script'].' </script>'."\n");}if(!isset($_GET['method'])||$_GET['method']!='ajax'){if(isset($CFG['content']['footer'])){print($CFG['content']['footer']);} works smooth and nice but as you already undestud that a back side of it is a forms... jquery's ajaxForms helped with sending requests and catching responce but i cant get it to "fadeTo" before showing responce $(document).ready(function(){$('#fileshare').ajaxForm( { target:'#content', beforeSubmit:showRequest, success:showResponse }); function showRequest(formData,jqForm,options){var queryString=$.param(formData);$('#content').fadeTo(500,0);return true;} function showResponse(responseText,statusText,xhr,$form){$('#content').fadeTo(500,1);} Edited October 1, 2012 by es131245 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now