Posts

Showing posts from May, 2018

Javascript Error : No 'Access-Control-Allow-Origin' header is present on the requested resource

Solution  - Add below code in Global.asax.cs file in API Project         protected void Application_BeginRequest(object sender, EventArgs e)         {             HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");             if (HttpContext.Current.Request.HttpMethod == "OPTIONS")             {                 HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache");                 HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");                 HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");                 HttpContext.Current.Response.AddHeader("Ac...

JavaScript ajax request

// Ajax Post & Get Methods var ajax = {     post: function (method, data, success, error) {         $.ajax({             url: GlobalValues.WebApiUrl + method,             type: "POST",             cache: false,             contentType: 'application/json; charset=utf-8',             transformRequest: function (obj) {                 var str = [];                 for (var p in obj)                     str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));                 return str.join("&");             },             headers: {      ...