验证javascript中wcf服务的端口是否正确

验证javascript中wcf服务的端口是否正确,javascript,ajax,json,wcf,service,Javascript,Ajax,Json,Wcf,Service,在我的javascript中,for循环中有10个不同的端口号,wcf服务托管在列出的10个端口中的一个端口号上 是否有任何方法可以通过使用loop进行检查,在使用ajaxjson的javascript中,我的服务在哪个端口号上响应良好,没有任何错误 这里我有示例代码,但我想检查10个不同的端口号: <script type = "text/javascript"> $("#search").live("click", function () { va

在我的javascript中,for循环中有10个不同的端口号,wcf服务托管在列出的10个端口中的一个端口号上

是否有任何方法可以通过使用loop进行检查,在使用ajaxjson的javascript中,我的服务在哪个端口号上响应良好,没有任何错误

这里我有示例代码,但我想检查10个不同的端口号:

<script type = "text/javascript">
    $("#search").live("click", function ()
    {
        var link = document.createElement('a');
        link.setAttribute('href', 'http://localhost:55154/Services/Service.svc/GetCustomers');
        alert(link.port);

        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: 'http://localhost:55154/Services/Service.svc/GetCustomers',
            data: '{"prefix": "' + $("#prefix").val() + '"}',
            processData: false,
            dataType: "json",
            success: function (response)
            {
                alert(response);
                //var customers = eval(response.d);
                //var html = "";
                //$.each(customers, function () {
                //    html += "<span>Name: " + this.Name + " Id: " + this.Id + "</span><br />";
                //});
                //$("#results").html(html == "" ? "No results" : html);
            },
            error: function (a, b, c) {
                alert(a.responseText);
            }
        });
    });
</script>

$(“#搜索”).live(“单击”,函数()
{
var link=document.createElement('a');
link.setAttribute('href','http://localhost:55154/Services/Service.svc/GetCustomers');
警报(链接端口);
$.ajax({
类型:“POST”,
contentType:“应用程序/json;字符集=utf-8”,
网址:'http://localhost:55154/Services/Service.svc/GetCustomers',
数据:“{”prefix:“+$(“#prefix”).val()+“}”,
processData:false,
数据类型:“json”,
成功:功能(响应)
{
警报(响应);
//var客户=评估(响应d);
//var html=“”;
//$。每个(客户、职能部门){
//html+=“Name:”+this.Name+“Id:”+this.Id+“
”; //}); //$(“#结果”).html(html==”?“无结果”:html); }, 错误:函数(a、b、c){ 警报(a.responseText); } }); });
循环并“ping”wcf服务以检测其位置不是一个好主意。我建议您定义一个静态wcf端口号

单击WCF属性,然后单击项目菜单“Web”并 配置选项“将服务器设置应用于所有用户(存储在 项目文件),因此请标记选项“使用Visual Studio开发” “服务器”和特定的端口号