Reading Time: < 1 minutes

I have just recently written a Web Shop plugin for some clients, but after upgrading one of their sites to WordPress 3.2.1 it made my checkout code flip backwards in ie7 and ie8.


After some debugging and googeling I found out that older versions of IE has some problems handling application/json mime type (This is the correct header content-type by the way). So instead of content-type application/json I had to change it to text/plain, pass the data as an array and then json_encode, this worked for IE9 but still not for IE7/8. So after a few hours of more debugging I came to realize that this thing works fine using WordPress 3.1.3, so I began to compare the differences. It turns out that the jquery form plugin I was using in WordPress 3.2.1 was not working so well, after copying over from 3.1.3 it was all good, even down to IE7.

So if you want to make IE happy, stay away from jquery form plugin 2.7.3 and use content-type: text/plain in your headers, below is an example of how I do this for the klarna gateway module to make it work:

// Ajax Form Options.
var options = {
    target: '#shop-ajax-response',
    beforeSubmit: validate,
    success: respond,
    url: shop_frontend_ajax.ajaxurl,
    data: {action: 'checkout_order'},
    dataType: 'json',
    cache: false
};

// Bind form using 'ajaxForm'.
jQuery("#dishop-checkout-form").ajaxForm(options);


$feedback .= '<p class="shop-message">'.$shop_gateway_msg.' | '.$klarna_result.'</p>';
if(defined('DOING_AJAX')) {
    $response = array('success' => false, 'modal' => true, 'feedback' => $feedback);
    header('Content-type: text/plain; charset=utf-8');
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: 0");
    echo json_encode($response);
    exit;
}

I know this is a half-way solution, I intend to notify about this problem so it can get fixed:)