I got the following error
GET http://localhost:61832/Service1.svc/data?ColumnName=FNAME 400 (Bad Request)
while executing the below javascript code:
$(document).ready(function () {
$('.filter').click(function () {
var pos = $(this).position();
var width = $(this).outerWidth();
var height = $(this).outerHeight();
var colName = $(this).attr("alt");
jQuery.support.cors = true;
$.ajax({
type: "GET",
url: "http://localhost:61832/Service1.svc/data?ColumnName=" + colName,
processData: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
},
error: function (xhr, status, error) {
alert(error);
}
});
});
$(document).mouseup(function (e) {
var container = $("#divFilterList");
if (container.has(e.target).length === 0) {
container.detach();
}
});
});
I have got another page that contains the same code with different hostname and is running fine. What can be the reason?? Kindly help!!
Edit: Here is the system.serviceModel of web.config file
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="NoSecurity">
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="GRDIVIEW EXCEL FILTER.Service1">
<endpoint address="" behaviorConfiguration="WebBehavior" binding="webHttpBinding" contract="GRDIVIEW EXCEL FILTER.IService1"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Here is the IService1.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace GRIDVIEW_EXCEL_FILTER
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet(UriTemplate = "/data?ColumnName={strColumnName}", ResponseFormat = WebMessageFormat.Json)]
FilterValueSet[] GetDistinctValue(string strColumnName);
}
}
and here the service1.svc.cs file:
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Configuration;
using System.Data;
namespace GRIDVIEW_EXCEL_FILTER
{
public class Service1 : IService1
{
public FilterValueSet[] GetDistinctValue(string strColumnName)
{
OracleConnection connection = null;
try
{
connection = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
string strOracle = string.Empty;
switch (strColumnName)
{
}
OracleCommand command = new OracleCommand();
command.CommandText = strOracle;
command.Connection = connection;
command.Connection.Open();
OracleDataReader dataReader = command.ExecuteReader(CommandBehavior.CloseConnection);
IList<FilterValueSet> filterValueList = new List<FilterValueSet>();
while (dataReader.Read())
{
filterValueList.Add(new FilterValueSet
{
Id = dataReader[0].ToString(),
Value = dataReader[1].ToString()
});
}
connection.Close();
return filterValueList.ToArray<FilterValueSet>();
}
catch (Exception ex)
{
}
}
}
public class FilterValueSet
{
public string Id { get; set; }
public string Value { get; set; }
}
}
What I have tried:
i have searched the web for possible answer...i am not quite hands on for javascript....