我正在尝试使用Andy Matthews自动完成jquery mobile here。我的客户端服务有一个使用参数的方法。我不知道如何更改我的客户端调用以接受参数?
这是我的客户端电话:
//WHERE DO I PUT INPUT PARAMETERS??
$("#searchBox").autocomplete({
method: 'POST',
target: $('#suggestions'),
source: "ClientService.svc/REST/GetStates",
link: 'target.html?term=',
minLength: 1
});
这是我的服务:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
public List<string> GetStates(string y)
{
List<string> x= GetData(y);
return x;
}
答案 0 :(得分:3)
看了source code后,该插件似乎不允许传递自定义POST
参数。用户在框中键入的内容是在名为term
的参数中发送的,但如果您无法修改服务,我会做的是修改代码的以下部分:
...
} else {
$.ajax({
type: settings.method,
url: settings.source,
// Change the following line
// data: { term: text },
// for:
data: { y: text },
...
很容易找到,因为整个插件中只有一个$.ajax
调用。