Search code examples
jqueryruby-on-railsajaxinternet-explorerauthenticity-token

Internet Explorer causes an Invalid Authenticity Token error


This works in all browsers except IE7 and IE8 ( and probably IE6 ).

For some reason it won't respect my Authenticity Token.

Any ideas, tips for debugging, workarounds?

My standard setup:

$(document).ajaxSend(function(event, request, settings) {
    if ( settings.type != 'GET' ) {
        settings.data = (settings.data ? settings.data + "&" : "")
            + "authenticity_token=" + encodeURIComponent( AUTH_TOKEN );
    }
});

My AJAX call:

$(".ajax-referral").click(function(){
  $.ajax({
      type: "POST", 
      url: $(this).parent("form").attr("action"), 
      data:$(this).parent("form").serialize(),
      dataType: "script",
      });
  return false;
});

Solution

  • This error was caused by using IETester in Parallels through Mac OSX. IETester does not hold Authenticity Tokens in its sessions.