I am working on a JavaScript project where I need to check which port number a WCF service is hosted on, out of a list of 10 different port numbers. I want to find out which port number the service responds to without any errors using AJAX JSON.
Although I have a sample code snippet below, I would like to iterate this process for all 10 different port numbers:
<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>