0

我尝试将参数传递给我的 Web 服务并在文本框中显示结果。我的网络服务正在工作。我在浏览器中调用了方法...我认为我的 Jquery 有问题。

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="QRCode.aspx.cs" Inherits="QRCODE_QRCode"
    meta:resourceKey="Page" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="System.Web.Ajax" Namespace="System.Web.UI" TagPrefix="asp" %>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >



<html>
<head id="Head1" runat="server">
   <title>Check-In & Check-Out </title>




<script language="javascript" type="text/javascript">


    function capture() {
        var urlValue = window.location;
        var urlText = urlValue.toString();
        var start = urlText.indexOf("=") + 1;
        var nameText = urlText.substring(start, urlText.length);
        document.getElementById('PanelID').value = nameText;
    }
    window.onload = capture


    function loadDate() {
           jQuery.support.cors = true;
           var PanelIDs = document.getElementById('PanelID').value;
          alert(PanelIDs);

          $.ajax({
              type: "POST",
              url: "http://entwicklung.de/Web/Service1.asmx/getDatetime",
              data: { "PanelIDs": PanelIDs },
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function(data) {

                  $("#textbox").text(data.d);
              },
              error: function(jqXHR, textStatus, errorThrown) {
                  alert(jqXHR);
                  alert(textStatus);
                  alert(errorThrown);
              }


          });

        }



</script>
</head>
<body>

<h1>Check-In und Check-Out von Besprechungen</h1>

<form id="form1" runat="server">
  <p>
     <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">  
     </asp:ToolkitScriptManager>  

    Raum: <asp:TextBox type="text" name="Panels" id="PanelID" value="" runat="server"></asp:TextBox>
    <br /> <br />



<asp:textbox ID="textbox" mode="multiline" runat="server" Coloumns="20" Rows="4" 
          Height="230px" Width="405px"></asp:textbox>



<asp:Button ID="button" runat="server" Text="Check-In"  Width="99px" 
      OnClientClick="return loadDate();"   />

<asp:Button ID="button1" runat="server" Text="Check_Out" Width="99px" />




  </p>
</form>
</body>
</html>

我在做什么错?感谢帮助

4

4 回答 4

0

data: "{ 'PanelID': '" + PanelIDs + "' }" 应该是 data: "{ 'PanelIDs' : '" + PanelIDs + "' }"

kay需要匹配属性名

于 2012-09-19T09:58:36.453 回答
0

首先测试您的网络服务网址和您的网络服务方法应该是公开的,并且您的网络服务网址与您的网络方法一样

      url: "www.entwicklung.de/Web/Service1.asmx/getDatetime",
于 2012-09-19T10:21:41.397 回答
0

您可以调整您的data- PanelIDs(with s in the end)

data: "{ 'PanelIDs': '" + PanelIDs + "' }"
于 2012-09-19T10:25:50.653 回答
0

'data' 应该是一个对象而不是 JSON 字符串:

data: { "PanelID": PanelIDs }
于 2012-09-19T09:47:54.427 回答