Jquery cross domain ajax request can be made by setting crossDomain property to true. For cross domain request we need to set some configurations in both the application’s web.config file.
<script> $(document).ready(function () { $.ajax({ type: 'GET', url: 'URL', crossDomain: true, data: {}, dataType: 'json', success: function (responseData, textStatus, jqXHR) { if (responseData != null) { $("#id").html(responseData); } }, error: function (responseData, textStatus, errorThrown) { $("#id").html(errorThrown); } }); }); </script>
For cross domain ajax request we need to set max Json Length in both the application’s web.config file. Put the below lines inside the Configuration section.
<system.web.extensions> <scripting> <webServices> <jsonSerialization maxJsonLength="900000"></jsonSerialization> </webServices> </scripting> </system.web.extensions>
For cross domain ajax request we need to add Custom Headers. Add these Custom Headers in both the application’s web.config file. Put the below lines inside System.WebServer section.
<httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*"/> <add name="Access-Control-Allow-Origin" value="Content-Type"/> </customHeaders> </httpProtocol>