"Message":"无效的 JSON 基元


 $.ajax({
                type: "post",
                url: "Handler.aspx/Val",
                contentType: "application/json",
                data:'{account:'+v+'}',
                dataType: "json",
                success: function (data) {
                    alert(data.d+"success");
                    // Play with returned data in JSON format
                },
                error: function (msg) {
                    alert(msg+"error");
                }

解决方案  data:'{account:"'+v+'"}',

注意data必须是一个“表示JSON对象的字符串”,而不是一个“JSON”对象

原因是jquery会把JSON对象序列化成标准POST的形式,ASP.NET WebService需要的是JSON格式的数据,所以必须把你的数据变成一个JSON样子的字符串

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM