I would like to convert a script I found ... But I can not. It works with Jquery 1.5. But it no longer works with Jquery 1.6.
Yet I tried jquery -migrate ( Migrate older jQuery code to jQuery 1.9+ ) . But without result ...
The script :
$.post('', form.serialize(), function(msg) {
        submitFlag = false;
        overlay.hide();
        $('span.errorIcon').remove();
        if (msg.success) {
            $('#formContainer, #mdiv, #contactboxfloat').fadeOut(function() {
                form.get(0).reset();
                $('#thankYou').fadeIn();
            });
        } else {
            $.each(msg, function(k, v) {
                var errorIcon = $('<span>', {
                    className: 'errorIcon'
                });
                var errorTip = $('<span>', {
                    className: 'errorTip',
                    text: v
                }).hide().appendTo(errorIcon);
                errorIcon.hover(function() {
                    errorTip.stop().fadeIn(function() {
                        errorTip.css('opacity', 1);
                    });
                }, function() {
                    errorTip.stop().fadeOut('slow', function() {
                        errorTip.hide().css('opacity', 1);
                    });
                });
                form.find('[name=' + k + ']').closest('.formRow').append(errorIcon);
                if ($(window).width() - errorIcon.offset().left > 240) {
                    errorTip.css('left', 30);
                } else {
                    errorTip.css('right', 30);
                }
            });
        }
    }, 'json');
php json
    if (!function_exists('json_encode'))
{
    function json_encode($a=false)
    {
        if (is_null($a)) return 'null';
        if ($a === false) return 'false';
        if ($a === true) return 'true';
        if (is_scalar($a))
        {
            if (is_float($a))
            {
                // Always use "." for floats.
                return floatval(str_replace(",", ".", strval($a)));
            }
            if (is_string($a))
            {
                static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
                return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
            }
            else return $a;
        }
        $isList = true;
        for ($i = 0, reset($a); $i < count($a); $i++, next($a))
        {
            if (key($a) !== $i)
            {
                $isList = false;
                break;
            }
        }
        $result = array();
        if ($isList)
        {
            foreach ($a as $v) $result[] = json_encode($v);
            return '[' . join(',', $result) . ']';
        }
        else
        {
            foreach ($a as $k => $v) $result[] = json_encode($k).':'.json_encode($v);
            return '{' . join(',', $result) . '}';
        }
    }
} 
Can someone explain to me what prevents the script work?
and
if($_SERVER['REQUEST_METHOD'] == 'POST'){
    try{
        $contactForm->validate();
        $contactForm->send();
        $thankYou = $config['thankYouMessage'];
        if(IS_AJAX){
            echo json_encode(array('success'=>1));
            exit;
        }
    }
    catch(FormValidateException $e){
        if(IS_AJAX){
            echo json_encode($e->errors);
            exit;
        }
        else{
            $contactForm->populateValuesFromArray($_POST);
        }
    }
    catch(Exception $e){
        die('{"exception":"'.$e->getMessage().'"}');
    }
}
