how to resolve cross-domain issues using wcf services
$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: 'http://localhost:49878/Employee.svc/GetEmployeeList', dataType: "json", success: function (data) { //alert(data.d); $($.parseJSON(data.d)).each(function (index, value) { $("#TableID").append("<tr><td>" + value.EmpId + "</td><td>" + value.EmpName + "</td><td>" + value.Desgination + "</td></tr>"); }); }, error: function (result) { // alert(result); } });
private static void ResponseHeaders() { WebOperationContext.Current.OutgoingResponse.Headers.Add( "Access-Control-Allow-Origin", "*"); WebOperationContext.Current.OutgoingResponse.Headers.Add( "Access-Control-Allow-Methods", "POST"); WebOperationContext.Current.OutgoingResponse.Headers.Add( "Access-Control-Allow-Headers", "Content-Type, Accept"); } public List<Employe> GetEmployeeList() { var listEmployee = new TestEntities().Employes.ToList(); ResponseHeaders(); return listEmployee; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)