0

I have web site project which contains app_code folder that contains ConnectCrm.cs. Also in this project i have VoC.cshtml file. I want to call method from ConnectCrm.cs file using ajax in VoC.cshtml file like this :

   <script type="text/javascript">
        $(document).ready(function () {
            $("#serialno").change(function () {
                $.ajax({
                    type: "POST",
                    url: "/App_Code/ConnectCrm.cs/CheckSerialNo",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function () {
                        alert($("#serialno").text());
                    },
                    error: function () {
                        alert('Hello');
                    }
                });
            });
        });
    </script>

But i couldn't. It gives me error continuously. i have no idea actually, this is possible with ajax or not.

4

1 回答 1

0

You need to make a webservice to handle the interaction with your .cs code on the backend.

There are several different kinds of webservices available in .net. To start, check out http://msdn.microsoft.com/en-us/library/ms464040(v=office.14).aspx for a tutorial on how to build a .asmx webservice.

于 2013-06-26T17:49:44.220 回答