{"id":1398,"date":"2010-04-21T16:10:16","date_gmt":"2010-04-21T06:10:16","guid":{"rendered":"https:\/\/eisabainyo.net\/weblog\/?p=1398"},"modified":"2010-04-21T16:13:55","modified_gmt":"2010-04-21T06:13:55","slug":"troubleshooting-jquery-get-cache-issue-in-internet-explorer","status":"publish","type":"post","link":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/","title":{"rendered":"Troubleshooting jQuery.get() Cache issue in Internet Explorer"},"content":{"rendered":"<p>There is an issue with <a href=\"http:\/\/api.jquery.com\/jQuery.get\/\">jQuery.get()<\/a> in Internet Explorer when trying to update content on the fly because IE caches XMLHttpRequest response and the AJAX call made via jQuery.get() is therefore always returning the same result.   I encountered this problem when I was writing a function similar to facebook Like feature where the Like counter increments by 1 whenever someone clicks on the I like it link.  It works all fine and well on Firefox, but when I tested it on IE, the counter doesn't increase as expected.  <\/p>\n<p>To solve the issue, I added a parameter to the request URL that is unique for each request by using Javascript getTime function.  Javascript getTime function returns the number of milliseconds since January 1, 1970. This prevents IE from returning the same\/cached response because the request URL is always unique.  <\/p>\n<p><strong>Javascript<\/strong><\/p>\n<pre>jQuery.fn.likeIt = function() {\r\n    var r = new Date().getTime(); \/\/ unique random number to workaround IE cache issue\r\n    $(\"a\", this).click(function() {\r\n        \/\/ Note: my href already has a parameter which is why I have &amp; instead of ? before the r parameter \r\n\t$.get($(this).attr(\"href\") + \"&r=\" + r, function(data) {  \r\n             \/\/ do your processing here\r\n\t}); \/\/ $.get\r\n    return false;\r\n    });\r\n};<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There is an issue with jQuery.get() in Internet Explorer when trying to update content on<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,16,11],"tags":[],"class_list":["post-1398","post","type-post","status-publish","format-standard","hentry","category-snippets","category-troubleshooting","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Troubleshooting jQuery.get() Cache issue in Internet Explorer | Tech Leadership Advice &amp; Resources<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Troubleshooting jQuery.get() Cache issue in Internet Explorer | Tech Leadership Advice &amp; Resources\" \/>\n<meta property=\"og:description\" content=\"There is an issue with jQuery.get() in Internet Explorer when trying to update content on\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/\" \/>\n<meta property=\"og:site_name\" content=\"Tech Leadership Advice &amp; Resources\" \/>\n<meta property=\"article:published_time\" content=\"2010-04-21T06:10:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2010-04-21T06:13:55+00:00\" \/>\n<meta name=\"author\" content=\"Isabel Nyo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Isabel Nyo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/\"},\"author\":{\"name\":\"Isabel Nyo\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"headline\":\"Troubleshooting jQuery.get() Cache issue in Internet Explorer\",\"datePublished\":\"2010-04-21T06:10:16+00:00\",\"dateModified\":\"2010-04-21T06:13:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/\"},\"wordCount\":148,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"articleSection\":[\"Snippets\",\"Troubleshooting\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/\",\"url\":\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/\",\"name\":\"Troubleshooting jQuery.get() Cache issue in Internet Explorer | Tech Leadership Advice &amp; Resources\",\"isPartOf\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#website\"},\"datePublished\":\"2010-04-21T06:10:16+00:00\",\"dateModified\":\"2010-04-21T06:13:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/eisabainyo.net\/weblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Troubleshooting jQuery.get() Cache issue in Internet Explorer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#website\",\"url\":\"https:\/\/eisabainyo.net\/weblog\/\",\"name\":\"Career Resources for Professionals in Tech\",\"description\":\"Books, worksheets, templates, frameworks and other useful resources for Chief Technology Officers (CTOs), VPs of Engineering &amp; Technology Directors\",\"publisher\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eisabainyo.net\/weblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\",\"name\":\"Isabel Nyo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g\",\"caption\":\"Isabel Nyo\"},\"logo\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/\"},\"description\":\"My interests: Web Development, Web Design, Web Applications, Web 2.0, AJAX, Search Engine Optimisation, Latest Technologies and more..\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Troubleshooting jQuery.get() Cache issue in Internet Explorer | Tech Leadership Advice &amp; Resources","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/","og_locale":"en_US","og_type":"article","og_title":"Troubleshooting jQuery.get() Cache issue in Internet Explorer | Tech Leadership Advice &amp; Resources","og_description":"There is an issue with jQuery.get() in Internet Explorer when trying to update content on","og_url":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/","og_site_name":"Tech Leadership Advice &amp; Resources","article_published_time":"2010-04-21T06:10:16+00:00","article_modified_time":"2010-04-21T06:13:55+00:00","author":"Isabel Nyo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Isabel Nyo","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/#article","isPartOf":{"@id":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/"},"author":{"name":"Isabel Nyo","@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"headline":"Troubleshooting jQuery.get() Cache issue in Internet Explorer","datePublished":"2010-04-21T06:10:16+00:00","dateModified":"2010-04-21T06:13:55+00:00","mainEntityOfPage":{"@id":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/"},"wordCount":148,"commentCount":4,"publisher":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"articleSection":["Snippets","Troubleshooting","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/","url":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/","name":"Troubleshooting jQuery.get() Cache issue in Internet Explorer | Tech Leadership Advice &amp; Resources","isPartOf":{"@id":"https:\/\/eisabainyo.net\/weblog\/#website"},"datePublished":"2010-04-21T06:10:16+00:00","dateModified":"2010-04-21T06:13:55+00:00","breadcrumb":{"@id":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/eisabainyo.net\/weblog\/2010\/04\/21\/troubleshooting-jquery-get-cache-issue-in-internet-explorer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/eisabainyo.net\/weblog\/"},{"@type":"ListItem","position":2,"name":"Troubleshooting jQuery.get() Cache issue in Internet Explorer"}]},{"@type":"WebSite","@id":"https:\/\/eisabainyo.net\/weblog\/#website","url":"https:\/\/eisabainyo.net\/weblog\/","name":"Career Resources for Professionals in Tech","description":"Books, worksheets, templates, frameworks and other useful resources for Chief Technology Officers (CTOs), VPs of Engineering &amp; Technology Directors","publisher":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eisabainyo.net\/weblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab","name":"Isabel Nyo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g","caption":"Isabel Nyo"},"logo":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/"},"description":"My interests: Web Development, Web Design, Web Applications, Web 2.0, AJAX, Search Engine Optimisation, Latest Technologies and more.."}]}},"_links":{"self":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts\/1398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/comments?post=1398"}],"version-history":[{"count":6,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts\/1398\/revisions"}],"predecessor-version":[{"id":1404,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts\/1398\/revisions\/1404"}],"wp:attachment":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/media?parent=1398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/categories?post=1398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/tags?post=1398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}