The problem:
I am using Jquery UI tabs. The tabs display data that is stored in a database. Lets say the tabs are on home.com. In order to edit data in the database, you are taken to a new page where you can edit the data (e.g home.com/edit). Once you go back to home.com the new data should be displayed. This is the case in google chrome and firefox, but not in Internet explorer.
The weirdness:
I can set $.ajaxSetup({cache:false}); and now the data is reloaded. Which makes me think it is an ajax issue with internet explorer (ignoring get requests). The trouble is that I don't want the cache to be set to false. I only want the tab to load once when the tab is click(styles, javascript, data, etc. do not need to be reloaded.). i.e. the tab should only be reloaded when you go to a different page and then come back, not each time you click the tab.
Also, When all of the IE windows are closed, and then navigate back to home.com, the updated data is displayed. Data is being refreshed on the site, but just not on pages where ajax calls are made. It seems like the behavior should be that ajax Get requests that are made should be ignored unless the whole page is refreshed, but the behavior appears to be that ajax Get requests are ignored unless the session is refreshed.
Hope that makes sense.
Any help is greatly appreciated!
Here is an example of what the code would look like:
html:
<div id='tabs'>
<ul>
<li><a href='Home.php?viewIsActive=true&tab=true'> Active </a></li>
<li><a href='Home.php?listAll=true&tab=true'> List All </a></li>
</ul>
</div>
Javascript:
$("#tabs").tabs();
Switching between tabs should cache, but reloading the page should reload the tabs as well.
Got it figured out!
Most information out there says to either use Jquery:
$.ajaxSetup({cache:false});
Or html header
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
The problem is that both of these get ride of caching altogether. In my situation I only wanted the ajax caching off, and only on page reloads, not within the page.
$.ajaxSetup({cache:false}); will add a timestamp to the ajax get url. The trouble is that each time you click the tab, a new timestamp is added, making IE think it's a new URL, and reloading all of the information.
Solution:
Add the timestamp to the server side. This way each time the page is reloaded and the server is contacted, there is a new timestamp. But when you are clicking around on the client side, IE doesn't reload the url since it is the same and only changes on page reloads/navigating away and back.
php:
$time = time();
$tabs = "<div id='tabs'>
<ul>
<li><a href='Home.php?viewIsActive=true&tab=true&timeStamp=" . $time . "'> Active </a></li>
<li><a href='Home.php?listAll=true&tab=true&timeStamp=" . $time . "'> List All </a> </li>
</ul>
</div>"
So, for ajax requests that you only want loaded once per page refresh/navigation, use server side timestamp, for ajax requests that you never want cached, use the jquery client side timestamp.
Related
<body>
<div data-anchor="page_1"></div>
<div data-anchor="page_2"></div>
<div data-anchor="page_3"></div>
<div data-anchor="page_4"></div>
</body>
When I open my home page http://my.site/index, the default page is
page_1 and there is no hash part #page_1 in URL.
I slid down the screen and current page changes to page_2 with URL
http://my.site/index#page_2
I navigate back and the URL changes to
http://my.site/index. The page is still on page_2 which I wanted
is page_1.
Are there some options on creating fullpage.js or should I set the default URL to http://my.site/index#page_1?
Unfortunately that's a well known bug in fullPage.js for which there's no solution so far.
You can read more about it on the repo's github issues forum:
https://github.com/alvarotrigo/fullPage.js/issues/950
To prevent this, you can force fullpage.js to ignore the anchors by using the options recordHistory: false or lockAnchors: true.
I have a page with a container that gets different content from an ajax request. This content has a form that posts data (and a file) to an iframe that is also in this ajax content container. I can submit the form and it works perfectly in Chrome, but Firefox and IE just sit there like I never clicked the submit button. I have default security settings on each browser, and don't want to change them for this functionality. Can anyone see any bugs in my code or process that would cause this? thanks in advance!
form:
<form action='processUploadFrame.php' method='post' enctype='multipart/form-data' id='myForm' target='iframeUpload'>
<input type='submit' value='Upload' />
iframe:
<iframe name='iframeUpload' frameborder=1 width=750 height=150></iframe>
Solved. My HTML 101 has failed me. Having my submit button in a different table cell than the rest of the form doesn't work in IE and FF, but Chrome is okay with it. Strange. A simple javascript submit link did the trick:
<a href='javascript:document.getElementById(\"myForm\").submit();'>Submit</a>
Here's an article that reminded me about the rules of such: http://www.cs.tut.fi/~jkorpela/forms/tables.html
So I am new to jQuery and I'm trying to set up an html page that has tabs. Each tab should show a different html page as follows:
<div id="tabs">
<div class="tabdiv tabActive">Page1</div>
<div class="tabdiv">Page2</div>
<div class="tabdiv">Page3</div>
<div class="tabdiv">Page4</div>
</div>
<div class="tabscontent" id="ajax-content">
Default text
</div>
So what I want is that when I click on page 1, page1.html will be loaded up in div.tabscontent. This is the jQuery code that I have.
$(document).ready(function() {
$("div#tabs a").click(function() {
alert(this.href);
$("#ajax-content").empty().append("Loading");
$("div#tabs div.tabdiv").removeClass('tabActive');
$(this).children('div.tabdiv').addClass('tabActive');
$.ajax({
url: this.href,
success: function(html) {
$("#ajax-content").empty().append(html);
alert("Success!");},
error: function() {
$("#ajax-content").empty().append("Didn't work");}
});
return false;
});
});
Note: 1) I have the latest jquery attached 2) I the page1.html, page2.html, etc are in the same folder as the above html file. 3) I am working locally and have tried google-chrome, firefox, and opera and they all had tabs that showed "Didn't work". Even when I reference http://www.facebook.com in the url it doesn't work. Please help me.
I put the alert in there to see if the href works and it does work. For example for page1 tab it returns `file:///u/b/user/Desktop/ajaxdemo/Page1.html'
In your case, it does not work because you're trying to access a file from user computer. It poses security risks because if javascript is able to access local files, javascript is able to steal files from client machine.
Even when I reference http://www.facebook.com in the url it doesn't
work
The reason for this is: AJAX requests are subject to the same-origin policy. Facebook is on another domain, that's why it does not work.
One more thing to keep in mind, some browsers think absolute URLs are cross-domain requests even if it's in the same domain, only relative Urls work, so avoid using absolute Urls.
To fix your issues, try deploying on a server and use relative URLs instead of absolute URLs.
I am trying to use lightbox plus plugin for Wordpress which works fine for most of my site.
I have a php page which is used by a jQuery AJAX function to retrieve data in order to paginate a large result set back in wordpress. This page is not part of wordpress.
I have managed to get Wordpress functions to work fine in this php page by using:
define('WP_USE_THEMES', false);
require('/home/love/public_html/dev/wp-blog-header.php');
require('/home/love/public_html/dev/wp-load.php');
However, in this page is an include, and within the included file is a link to an external sheet which is meant to be brought in with a lighbox:
<a class="" rel="lightbox" href="<?php bloginfo('url'); ?>/more-product-info?a=<?php echo $post->ID ?>">
<div id="moreprodinfo">More Info</div>
</a>
This method of retrieving information in a lighbox works ok on most parts of my site, but its just not working on the part that uses AJAX to retrieve the link to the lighbox page.
I assumed it was something to do with plugins not working when the page is not part of Wordpress, but all the Wordpress function have been working so why not plugins? Also my cufon plugin doesnt work on this ajax retrieved page either.
Is it becuase I am using .html javascript function to display the content retrieved by AJAX:
if(pageType == 'prizeHome'){
loading_hide();
$("#tab-prize-home #container").html(msg);
Any help would be appreciated
It looks like a common issue when using ajax to load html content :
You probably call lightbox and cufon when document is ready, which happens only once before your ajax call. You have to call again lightbox and cufon after your ajax call.
Is there an easy way of automating clicking on a certain button on a website?
I'm trying to help someone in my company out, the guy basically stares a booking page the entire day, having to click on a single button to refresh the page. If new booking slots becomes available, then it will only be shown on the page on the page refreshes, which means, the guy needs to click on the button the entire day...
Is there a way of maybe automating this? cUrl? Ruby?
If you just refresh the browser to make it refresh then you could try a reload plugin like https://addons.mozilla.org/en-US/firefox/addon/115/. If you actually have to click the button then you could put together a very simple greasemonkey( https://addons.mozilla.org/en-US/firefox/addon/748/ ) script which just simulates a mouse click. With jQuery it would be something like
$("#buttonid").click()
triggered by any one on a hundred timer plugins or setTimout.
First of all i think i have understand your question correctly. What you are trying to do here is that periodically refresh an external web page (say www.google.com)
If so do something like this
create an html page
test.html
and create an iframe inside it and give the url of the web page that you want to refresh
iframe src="http://www.google.com">
and then in the head section add
META HTTP-EQUIV="REFRESH" CONTENT="5" to refresh the page
Ex:
html
<head>
<META HTTP-EQUIV="REFRESH" CONTENT="5">
</head>
<body>
<iframe src="http://www.google.com"></iframe>
</body>
html
Hope you find this helpful (as i said if i understood the question correctly)
cheers
sameera