当前位置:编程学习 > C#/ASP.NET >>

asp.net jquery ajax返回值并输出

asp教程.net jquery ajax返回值并输出
本文章是讲一款关于jquery ajax返回值如何让asp.net教程接收并且输出实例代码。

<script language="网页特效" src="js/jquery-1.3.2.min.js"></script>
     <script type="text/javascript">
         var url = "webform2.aspx";
         var obj = new object();
         obj["bh"] = "1";
         obj["xm"] = "刘生";
         var aa = ajaxrequest(url, obj);
         function ajaxrequest(url, obj) {
             var entity = null;
             $.ajax({
                 contenttype: "application/json",
                 url: url,
                 type: 'post',
                 async: false,
                 datatype: 'json',
                 data: obj,
                 success: function(data) {
                     if (data != null) {
                         entity = data;
                     }
                 },
                 error: function() {
                     alert("报错啦!");
                 }
             });
             return entity;
         }
     </script>
    
     aspx接收数据
    
     response.write("{name: 'abc'}");
success: function(data) {
      alert(data);//输出{name: 'abc'}
      var o = eval("(" + data + ")");
      alert(o.name);//输出abc
  }
补充:asp.net教程,.Net开发
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,