小编Den*_*nis的帖子

无法使用ajax调用将值传递给Web服务

我不知道我的数据语法是否错误,但是当没有传递参数时这个相同的脚本正在工作,但是当传递参数时,它不起作用.为什么?

 <script type="text/javascript" src="jquery-1.7.2.min.js"> 
      <script type="text/javascript">
       function GetAge() {
           var StrYear = document.getElementById("StringYear").value;
           var StrMonth = document.getElementById("StringMonth").value;
           var StrDay = document.getElementById("StringDay").value;
           jQuery.support.cors = true;
           $.ajax({
               type: "POST",
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               jsonp: 'jsonp_callback',
               async: false,
               url: 'http://localhost:50113/Service1.asmx/GetAge',
               data: "{ StrYear: "+StrYear+", StrMonth:"+ StrMonth+"  , StrDay: "+StrDay+"  }",
               success: function (msg) {
                   $('#divToBeWorkedOn').html(msg.d);
               },
               error: function (e) {
                   $('#divToBeWorkedOn').html("Unavailable");
               }
           });
         }
        </script> 
Run Code Online (Sandbox Code Playgroud)

html javascript jquery json

0
推荐指数
1
解决办法
190
查看次数

标签 统计

html ×1

javascript ×1

jquery ×1

json ×1