0

这是我的带有 json 的 jquery

 $('#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 !!!!!!!!!!!!');
                    }
                });
            });

还有我的 C# 方法:

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

它总是提醒'错误错误!!!!!!!!!!!!' 我尝试调试,但 CompleteTransactions 方法没有触发

这是我的第二个 json,它在下面并且效果很好

$('#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.');
                        }
                    });
                }
            });
4

1 回答 1

3

我不是 100% 确定,但你不应该是控制器动作处理程序public吗?

于 2012-05-15T20:17:08.227 回答