使用JQuery ajax webservice的唯一值 [英] unique values using JQuery ajax webservice

查看:78
本文介绍了使用JQuery ajax webservice的唯一值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个网站并使用jquery来调用webservice。但是我的web服务在数组中重复了重复的值。



如何在jquery ajax调用中删除这些值和唯一值?

i am building a web site and use jquery to call the webservice. but my webservice resturns duplicate values in a array.

how can i remove those values and only unique values in jquery ajax call?

推荐答案

任何努力?这已经做过很多次,互联网上充满了这样的例子。



但是,我的第一个问题是你是否掌控了网络服务?如果是,我宁愿删除Web服务方法本身的重复值。它将为您提供一个优势,即您将在Web服务的所有消费者中拥有类似的行为。



否则,您可以使用以下链接开头:



http:/ /manasbhardwaj.net/get-unique-values-from-a-javascript-array-using-jquery/



免责声明:指向我自己的文章。



Any effort? This has been done so many times before and internet is full of such examples.

However, my first question would be if you are in control of the web service? If yes, I would rather remove the duplicate values on the web service method itself. It will give you an advantage that you will have similar behaviour across all consumers of your web service.

Otherwise, you could use the link below to start with:

http://manasbhardwaj.net/get-unique-values-from-a-javascript-array-using-jquery/

Disclaimer: Points to my own article.

function GetUnique(inputArray)
{
	var outputArray = [];
	for (var i = 0; i < inputArray.length; i++)
	{
		if ((jQuery.inArray(inputArray[i], outputArray)) == -1)
		{
			outputArray.push(inputArray[i]);
		}
	}
	return outputArray;
}


这篇关于使用JQuery ajax webservice的唯一值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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