Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    May 2009
    Thanked 62 Times in 61 Posts

    Question jQuery $.post not working in IE

    Well I'm stumped.

    I'm putting a site together that loads/updates sections via AJAX with a hashed URL... so for anyone unfamiliar, links look something like this:
    <a href="#!/SomePage">Some Page</a>
    And the HTML associated with "SomePage" gets loaded into the main content (or whatever) via AJAX.

    For browsers with javascript disabled (and search engines), I also have pages with that content already included... so http://mysite.com/SomePage looks the same as if it were loaded via AJAX a la http://mysite.com/#!/SomePage.

    So to know when the hash has been changed (so I can then fetch/load the content) I'm using a jQuery plugin called hashchange which works wonderfully across all browsers I've tried.

    All of the text above might actually be irrelevant to the actual problem but I figured it might provide a little more insight to those kind enough to offer their guidance.

    To fetch the pages via AJAX/hashchange, I send a key/value (just "DoHash=1") via POST. The real problem is that IE never posts that data.

    A couple of things I read on the net regarding a similar problem state that it has to do with the caching of pages; but according to jQuery's docs, the $.post function does not cache:
    Pages fetched with POST are never cached
    This code works in Chrome, FF, Opera, and Safari... but not IE (I've only tried IE8 so far):
    		var hash = location.hash;
    		if (hash.substring(0,3) == '#!/') {
    			$.post(hash.substring(2), 'DoHash=1', function(R){
    				var n = R.indexOf("\n");
    				var J = jQuery.parseJSON(R.substring(0,n));
    				if (J.Title) document.title = J.Title;
    I've added an alert right before the $.post function and it alerts every time, which means it most definitely reaches the $.post function... but according to the server, it never actually posts anything, so I'd assume the problem must be with the $.post function itself.

    Any ideas?

    OH WOW... I just figured out what the problem was after trying a few things. This is so stupid... yet another reason to hate IE. I wonder how many total man hours have been wasted by developers troubleshooting IE.

    The problem was that any time the URL looked like this:

    IE would not perform any XHR.

    The URL has to look like this:

    Last edited by tfburges; 07-19-2011 at 03:59 PM.
    I'm the founder of Loggur, a place to build and share web apps focused on maximizing efficiency and productivity:

    My personal site and blog:

  2. AdSlot6


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts