我嘗試將一個參數傳遞給我的Web服務並在文本框中顯示結果。我的Web服務正在運行。我在瀏覽器中調用了方法...我認爲我的Jquery出了問題。從Ajax向Webservice傳遞參數
<%@ 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>
iam做錯了什麼?感謝您的幫助
使用誤差函數來看看是什麼錯誤。 http://api.jquery.com/jQuery.ajax/ –
我使用了errorFunction。錯誤是「沒有運輸」 – Paks
http://stackoverflow.com/questions/5241088/jquery-call-to-webservice-returns-no-transport-error –