无法在asp.net中使用Jquery Ajax调用调用Web方法 [英] Not able to call Web Method using Jquery Ajax Calls in asp.net

查看:95
本文介绍了无法在asp.net中使用Jquery Ajax调用调用Web方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图在jquery按钮单击事件uisng jquery ajax调用上调用web方法,但是在mscorlib中发生异常System.Threading.ThreadAbortException类型的第一次机会异常 .dll在visual studio的输出文件中。(我正在使用Visaul Studio 2012 WebExpress)



Hi,
I am trying to call a web method on jquery button click event uisng jquery ajax calls, But getting Exception "A first chance exception of type System.Threading.ThreadAbortException' occurred in mscorlib.dll" in output file of visual studio.(I am using the Visaul Studio 2012 WebExpress)

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>

               <script type="text/javascript">
                       $(document).ready(function () {
                           $("#btnUploadFile").click(function (e) {
                               $.ajax({
                                   type: 'POST',
                                   data: '{name: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',
                                   url: "AllEmployees.aspx/UploadEmployees",
                                   contentType: "application/json; charset=utf-8",
                                   dataType: "json",
                                   success: function (msg) {
                                       alert(msg);
                                   }
                               });
                               e.preventDefault();
                           });
                       });
                   </script>













[System.Web.Services.WebMethod]
             public string UploadEmployees(string name)
                    {
                        try
                        {
                            name="hi";
                           return msg;
                        }
                        catch (Exception)
                        {

                            throw;
                       }

                    }

推荐答案

(document).ready(function( ){
(document).ready(function () {


(#btnUploadFile)。click(function(e){
("#btnUploadFile").click(function (e) {


.ajax({
type:'POST ',
数据:'{name:'+
.ajax({ type: 'POST', data: '{name: "' +


这篇关于无法在asp.net中使用Jquery Ajax调用调用Web方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆