Jquery Ajax访问 .aspx

注意: 客户端用 下面方式:

Jquery Ajax访问 .aspx
   function tst() {

            var url = location.pathname + $.query.toString() + "&JSONTAG=onGetNewCode&fl=1" + "&t333=" + (+new Date());

            $.ajax({

                type: 'POST',

                url: url,

                data: { username: 'phpernote', password: '123456',ssid:1 },

                dataType: 'json',

                contentType: "application/json; charset=utf-8",

                timeout: 30000,

                cache: false,

                async: true,

                beforeSend: function () {

                    alert('请求之前');

                },

                success: function (data) {

                    alert('请求成功');

                },

                error: function (msg) {

                    alert('请求发生错误');

                }

            });

            

        }
View Code

服务器端用下面方式接收:

 

            String s = (new System.IO.StreamReader(Request.InputStream)).ReadToEnd();

          

2:

如果客户端不用:contentType: "application/json; charset=utf-8",

则服务器端用:Request就可访问


 

你可能感兴趣的:(jQuery ajax)