Irakli Lekishvili
Irakli Lekishvili

Reputation: 34158

asp.net mvc 3 json does not work

This is my jquery with json

 $('#btnVerificationOk').click(function () {
                var verId = $('#trans_verification_id').val();
                var verCode = $('#trans_verification_code').val();

                $.ajax({
                    url: '/Profile/CompleteTransactions',
                    type: 'POST',
                    data: {  },
                    dataType: 'json',
                    success: function (result) {
                        alert(result);
                    },
                    error: function () {
                        alert('ERROR ERROR !!!!!!!!!!!!');
                    }
                });
            });

And My C# method:

 [Authorize]
        [HttpPost]
        private JsonResult CompleteTransactions()
        {
            return Json("Done");
        }

Its always alerts 'ERROR ERROR !!!!!!!!!!!!' i tried debugging but CompleteTransactions method is not firing

And this is my second json which is bellow and works good

$('#btnTransfareOk').click(function () {
                var userName = $('#transfare_username').val();
                var amount = $('#transfare_amount').val();
                if (userName == '' || amount == '') {
                    $('#transfare_error_list').html('Please fill boxes.');
                } else {
                    $.ajax({
                        url: '/Profile/TranfareMoney',
                        type: 'POST',
                        data: { ToUsername: userName, Amount: amount },
                        dataType: 'json',
                        success: function (result) {
                            $('#transfare_error_list').html(result.text);
                            $('#trans_verification_id').val(result.id);
                            $('#transfare_username').val("");
                            $('#transfare_amount').val("");
                        },
                        error: function () {
                            $('#transfare_error_list').html('Oops... Error.');
                        }
                    });
                }
            });

Upvotes: 0

Views: 315

Answers (1)

a1ex07
a1ex07

Reputation: 37354

I'm not 100% sure, but shouldn't you controller action handler be public ?

Upvotes: 3

Related Questions