JQuery Mobile Autocomplete POST Add Parameter

I am trying to use Andy Matthews autocomplete for jQuery mobile found here . My client service has a method that uses a parameter. I'm not sure how to change my client call to accept parameters?

Here is my client call:

//WHERE DO I PUT INPUT PARAMETERS?? $("#searchBox").autocomplete({ method: 'POST', target: $('#suggestions'), source: "ClientService.svc/REST/GetStates", link: 'target.html?term=', minLength: 1 }); 

Here is my service:

  [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; } 
+4
source share
1 answer

After looking at the source code, it seems that the plugin does not allow passing custom POST parameters. What the user enters into the field is sent with the term parameter, but if you cannot change your service, then I would do this by changing the following part of the code:

 ... } else { $.ajax({ type: settings.method, url: settings.source, // Change the following line // data: { term: text }, // for: data: { y: text }, ... 

This is fairly easy to find, as there is only one call to $.ajax throughout the plugin.

+3
source

Source: https://habr.com/ru/post/1445147/


All Articles