Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had the same problem with you, in my previous <a href="https://stackoverflow.com/questions/17476364/jquery-ajax-request-not-found-servicestack-cross-domain-solved">question</a></p> <p>You can read very helpful answers of #mythz <a href="https://stackoverflow.com/questions/13741397/servicestack-cors-feature/13750561#13750561">here</a> and <a href="https://stackoverflow.com/questions/8211930/servicestack-rest-api-and-cors">here</a> .</p> <p>The code I use in the AppHost</p> <pre><code> using System.Web; using ServiceStack.WebHost.Endpoints.Extensions; // for httpExtensions methods // =&gt; after v.3.9.60, =&gt;using ServiceStack; </code></pre> <p>and </p> <pre><code> public override void Configure(Container container) { SetConfig(new ServiceStack.WebHost.Endpoints.EndpointHostConfig { DefaultContentType = ContentType.Json, ReturnsInnerException = true, WsdlServiceNamespace = "http://www.servicestack.net/types" }); Plugins.Add(new CorsFeature()); this.RequestFilters.Add((httpReq, httpRes, requestDto) =&gt; { //Handles Request and closes Responses after emitting global HTTP Headers if (httpReq.HttpMethod == "OPTIONS") httpRes.EndServiceStackRequest(); //httpExtensions method // =&gt;after v.3.9.60, =&gt; httpRes.EndRequestWithNoContent(); }); Routes .Add&lt;TestRequest&gt;("/TestAPI/Reservation", "POST, OPTIONS"); // OPTIONS is mandatory for CORS } </code></pre> <p>and in JavaScript like you </p> <pre><code> jQuery.support.cors = true; function TestRequestCall() { var TestRequest = new Object(); TestRequest.Id = 11111; TestRequest.City = "New York"; $.ajax({ type: 'Post', contentType: 'application/json', url: serverIP +'/TestAPI/Reservation', data: JSON.stringify( TestRequest ), dataType: "json", success: function (TestResponse, status, xhr) { if(TestResponse.Accepted) doSomething(); }, error: function (xhr, err) { alert(err); } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload