我正在尝试从 jquery 获取 wcf 服务。我写了下面的代码,但出现错误。
jQuery代码:
function LoadAutoComplete(method, param) {
firstIncrement = pageSize + 1;
$.ajax({
type: "POST",
url: "Services/Popup.svc/" + method,
dataType: "json",
contentType: "application/json; charset=utf-8",
data: params,
processdata: true,
success: function (data) {
if (data.PopupData != null) {
alert(data);
}
else {
//response = null;
//return response;
}
},
error: function (result) { alert("Error"); }
});
}
function LoadTest(id) {
var prm = "<%= this.Sequence %>";
var params = '"sequence":' + prm;
method = "GetNotes";
LoadAutoComplete(method,params);
}
.aspx 页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="JS/Popup.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
LoadAutoComplete("GetNotes","<%= this.Sequence %>");
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
GetNotes 是我用业务逻辑编写的方法名称。
错误:Microsoft JScript 运行时错误:“$”未定义