本文介绍了如何通过按钮1单击ajax的开头来触发button2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过单击按钮1的Ajax开头触发Button2?



我目前收到错误:

TS7027检测到TypeScript无法访问的代码。对于jQuery jquery-1.4.1.js

How do I trigger Button2 by clicking the start of a Ajax by Button1?

I am currently getting the error:
TS7027 TypeScript Unreachable code detected. For jQuery jquery-1.4.1.js

<script type="text/javascript" src="~/Scripts/jquery-1.4.1.js"></script> not loading.

This works till after Textbox4 is filled with the result of the WebMethod.
<pre lang="Javascript"><script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%= Button1.ClientID %>").click(function () {
                var mo1 = $("#<%= TextBox1.ClientID %>").val();
                var dy1 = $("#<%= TextBox2.ClientID %>").val();
                var yr1 = $("#<%= TextBox3.ClientID %>").val();
                var data = { mo:mo1, dy:dy1, yr:yr1 };
                var json1 = JSON.stringify(data);
                $.ajax
                ({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    data: json1,
                    url: "Default.aspx/GetDate",
                    success: function (result) {
                        $("#<%= TextBox4.ClientID %>").val(result.d);
                        $("#<%= Button2.ClientID %>").trigger("click");
                    },
                    error: function (status, ex) {
                        alert("Error Code: Status: " + status + " Ex: " + ex);
                    }
                });
                return false;
            });
        });
    </script>





我尝试过:



我试过$(#<%= Button2.ClientID%>)。click();



What I have tried:

I tried $("#<%= Button2.ClientID %>").click();

推荐答案




这篇关于如何通过按钮1单击ajax的开头来触发button2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:16