你如何使用POST使用jQuery Autocompleter? [英] How do you use POST with jQuery Autocompleter?

查看:98
本文介绍了你如何使用POST使用jQuery Autocompleter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的jQuery 1.2.6

jQuery v1.2.6

jQuery.autocompleter插件V1.1 pre(从jQuery的网站)

jQuery.autocompleter plugin v1.1pre (from jQuery's website)

我不能用'类型:POST'提交回我的web服务。我不能让它受autocompleter的认可。思考?

I am not able to submit with 'type: "POST"' back to my webservice. I can't get it to be recognized by the autocompleter. Thoughts?

这code以下工作得很好,只要我认准Q查询字符串。但是,我想通过传递更多的PARAMS使用这个在未来更先进的功能,并且将AP preciate怎么回发使用autocompleter。

This code below works fine, as long as I look for the "q" querystring. But, I would like to use this for more advanced features in the future by passing more params, and would appreciate how to post back using the autocompleter.

我知道了extraParams选项。但是,这些都是通过获得GET或POST提交的(如果我们能得到POST工作)额外的参数。它不会改变它提交一个POST。

I am aware of the extraParams option. But, those are extra parameters that get submitted via GET or POST (if we can get POST working). It doesn't change it to submit as a POST.

$(function() {
	$('#searchBox').autocomplete(
		"/services/college.asmx/lookupColleges",
		{
			delay: 5,
			minChars: 1,
			matchSubset: 1,
			matchContains: 1,
			cacheLength: 10,
			autoFill: false,
			dataType: 'json',
			parse: function(data) {
				var rows = new Array();
				for (var i = 0; i < data.length; i++) {
					rows[i] = {
						data: data[i]
						, value: data[i].Data
						, result: data[i].Name
					};
				}
				return rows;
			},
			formatItem: function(row, i, n) {
				return row.Name;
			}
		}).result(function(event, row) {
			processSelection(this, row.Data);
		});
});

我尝试添加的选项POST,如下面的code样品中指出。但它仍然作为提交一个GET。

I tried adding the option for POST, like noted in the code sample below. But it still submits as a GET.

delay: 5,
minChars: 1,
matchSubset: 1,
matchContains: 1,
cacheLength: 10,
autoFill: false,
dataType: 'json',
type: 'POST',

任何帮助是AP preciated。

Any help is appreciated.

感谢您!

PS,很多这是无证,而且是一个PITA反复试验后,要弄清楚。谢天谢地Firebug的。

PS, lots of this is undocumented, and was a PITA to figure out after trial and error. Thank goodness for Firebug.

您会注意到,我是:


  • 从web服务接收回JSON

  • 自动完成无法处理原生JSON,所以我必须把它解析到我自己的数组中。

  • 既然我现在回传一个自定义的数组对象,则需要formatItem为了处理新的数组对象展示的目的被覆盖。

  • 最后钱拍摄,我想在用户选择一个行(鼠标点击或TAB或ENTER键)之后处理该行上的额外的数据。我这样做的结果是()的委托。

我真的希望上述code在未来弄不清autocompleter帮助其他人。给我投票了,如果它。

I really hope the above code helps others in the future figure out the autocompleter as well. Give me a Vote Up if it does.

提示:属性名数据[I]。数据和数据[I] .Name点是JSON属性名

Tip: The property names data[i].Data and data[i].Name are the JSON property names.

推荐答案

在这个时候(Autocompleter 1.1 pre),没有办法得到它后不改变插件的code

At this time (Autocompleter 1.1pre), there isn't a way to get it to post without changing the plugin's code.

我刚刚离开它提交查询字符​​串现在。谢谢大家的回答,我调升表决。

I just left it submitting querystrings for now. Thank you all for answered, I upped the vote.

这篇关于你如何使用POST使用jQuery Autocompleter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆