asmx web service - jQuery ajax post json (500 error) - CORS (Access-Control-Allow-Origin is set to *)
I tried something simillar via JSONP. I think I based the solution off this article.
Another potential thing is that putting in your JSON as a string to a WCF service typically does not end well (I know this is not WCF, just saying it could be the same issue). I usually do this:
Using jQuery:$.ajax({ type: "POST", url: "http://somedomain/subscription/MyService.asmx/HelloWorldX", processData: false, data: JSON.parse('{ "SubReq" : {"EmailAddress":"user@test.com"} }'), dataType: "json", contentType: "application/json; charset=utf-8", cache: false, success: function(data, textStatus, jqXHR) { ajaxSucccess3(data, textStatus, jqXHR); }, error: function(jqXHR, textStatus, errorThrown) { console.log("Retrieve Hello Failed (AJAX Error): " + jqXHR.statusText + " | " + textStatus + " | " + errorThrown); }});}
The use of JSON.parse will also catch any bad JSON that goes through.
Hope this will fix your issue.