0

i try to pass a Parameter to my Webservice and show the result in a textbox. My Webservice is working. I invoked the Method in the Browser... I think that something is wrong with my 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>

What iam doing wrong? Thanks for help

Paks
  • 1,460
  • 6
  • 26
  • 46

4 Answers4

0

The 'data' should be an object rather than a JSON string:

data: { "PanelID": PanelIDs }
sphair
  • 1,674
  • 15
  • 29
0

data: "{ 'PanelID': '" + PanelIDs + "' }" should be data: "{ 'PanelIDs': '" + PanelIDs + "' }"

The kay needs to match the property name

Christian Phillips
  • 18,399
  • 8
  • 53
  • 82
0

first test your web-service url and ur method of web service should be public and your web service url with ur web method like

      url: "www.entwicklung.de/Web/Service1.asmx/getDatetime",
Anant Dabhi
  • 10,864
  • 3
  • 31
  • 49
0

You can adjust your data - PanelIDs (with s in the end)

data: "{ 'PanelIDs': '" + PanelIDs + "' }"
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51