Javascript Tooltip / Posts /

AJAX not refreshing the tooltip content?

616

I was just trying the tooltip AJAX.  The line is:

<b onmouseover="tooltip.ajax(this,'test.txt')">Click Me</b>

"test.txt" has only one word "HELLO". 

When the mouse is moved over "Click Me", tooltip shows "HELLO", which is correct.

Then I change the "test.txt" content to "WORLD".

When the mouse is moved over "Click Me", tooltip still shows "HELLO".  Even the page is refreshed, tooltip still shows "HELLO".

When I reopen the browser, tooltip now shows "WORLD".

Did I miss anything in the code that cause tooltip fails to retrieve the content dynamically?

My browser is IE 10.


 

Wilson  4 years ago   viewed: 7990    

3 Answers

1
It is due to the browser's cache of your test.txt file.

If your content is really dynamic, you can add the below parameter to your ajax url: new Date().getMilliseconds()
For example:
<b onmouseover="var timer = new Date().getMilliseconds(); tooltip.ajax(this,'test.txt?'+timer)">Click Me</b>

Note: usually you don't need to bother with this. Just refresh your browser is OK if your content will not be manually updated or the content is not dynamic.
milo
  4 years ago
-1

Yes it works, thank you.

My application is about displaying the stock quote when users mouse over a stock name, so a dynamic update of content is a must.

Wilson   4 years ago
2
Some users ask for the opposite: How to always get the cached data instead of hitting the server or database again and again. 
Here is the post to answer that question: 
Milo   3 years ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: