单击“确定”时,jquery警告框从数据库中获取值

时间:2013-09-19 10:58:27

标签: javascript jquery alert

我从电子邮件字段的数据库中获取值,当模糊功能提供警报消息时。在该警报消息中,如果我单击确定意味着它将获取配置文件并在我的视图中显示..是否可能?

Jquery代码:

<a id="checkEmail" href="#" ></a> | <a id="getCandidate"></a>

            <script type ="text/javascript">
                $('#getCandidate').text('Get Profile') // Sets text for email.
                    .attr('href', '#');

                $("#Email").blur(function () {
                    $('#checkEmail').trigger('click');
                    $('#getCandidate').text('Get Profile')
                    .attr('href', 'GetCandidateDetail?validateEmail=' + $('#Email').val());
                });


                $(document).ready(function () {
                    $('#checkEmail').click(function () {
                        var name = $('#Email').val();
                        var data = 'validateEmail=' + name;
                        $.ajax({
                            type: "GET",
                            url: "ValidateCandidate",
                            data: data,
                            success: function (data) {
                                alert(data);

                            }
                        });
                        return false;
                    });
                });
          </script>

2 个答案:

答案 0 :(得分:1)

我找到了结果..只需在ajax帖子中传递url,如下所示,

<script>

$(document).ready(function () {
                        $('#emailcheck').click(function () {

                            var name = $('#Email').val();
                            var data = 'getemail=' + name;
                        $.ajax({
                            type: "GET",
                            url: "geturl",
                            data: data,
                            success: function (data) {
                                window.location = "/home/homeurl/GetDetails?email=" + name;
                                alert(data);
                            }

                        });
                        return false;
                    });
                });
          </script>

答案 1 :(得分:0)

如果您使用确认框,则可以。这是示例代码。

        <a id="checkEmail" href="#" ></a> | <a id="getCandidate"></a><script type ="text/javascript">
            $('#getCandidate').text('Get Profile') // Sets text for email.
                .attr('href', '#');

            $("#Email").blur(function () {
                $('#checkEmail').trigger('click');
                $('#getCandidate').text('Get Profile')
                .attr('href', 'GetCandidateDetail?validateEmail=' + $('#Email').val());
            });


            $(document).ready(function () {
                $('#checkEmail').click(function () {
                    var name = $('#Email').val();
                    var data = 'validateEmail=' + name;
                    $.ajax({
                        type: "GET",
                        url: "ValidateCandidate",
                        data: data,
                        success: function (data) {
                            if (confirm("Press a button!"))
                            {
                               //Do you changes 
                            }
                        }
                    });
                    return false;
                });
            });
      </script>