CaptchaMvc与Ajax

I'm using mvc4 c# and view with a form inside a CaptchaMvc.

I send the form data over ajax :

$.ajax({
            url: $('#registerForm').attr("action"),
            type: 'POST',
            contentType: 'application/json',
            dataType: 'json',
            data: JSON.stringify($('#registerForm').serialize()),
            beforeSend: function () {

            },
            success: function (result) {
                //debugger;


            },
            error: function (event, request, settings) {
                //debugger;

            }
        });

I can see on firebug that "CaptchaInputText" sended to server, but still I get error

[NullReferenceException: Object reference not set to an instance of an object.]
CaptchaMvc.Infrastructure.DefaultCaptchaManager.ValidateCaptcha(ControllerBase controller, IParameterContainer parameterContainer) in g:\CodePlex\Captcha\CaptchaMvc(Mvc 3)\Infrastructure\DefaultCaptchaManager.cs:435

and It occur if I have the line :

[CaptchaMvc.Attributes.CaptchaVerify("Captcha is not valid")] 

on the controller action, If not ,there is no error but the captcha not getting validated. what to do ?

Try to change your request like this:

$.post($('#registerForm').attr("action"), $('#registerForm').serialize(),
        function(data) {

        }
    );

I've updated the examples and added an example with ajax request, you can download it here.