The goal is to make a ajax call that deletes stored searches of a user.
The method looks like this:
[HttpPost]
[ActionName("DeleteStoredSearch")]
public HttpResponseMessage DeleteStoredSearch(StoredSearch request)
{
_service.StoredSearchDelete(request.StoredSearchId);
return new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
}
The ajax call looks like this:
$.ajax({
type: "POST",
url: "https://" + domain + "/buyer/api/v1_0/FacetedSearchApi/DeleteStoredSearch",
data: { "StoredSearchId": search_id },
success: function (result)
{
console.log('Successfully called');
$this_element.closest('.listing').remove();
var thing = document.getElementById('searchcount').innerHTML;
var thenumber = thing.match(/\d+/)[0]
document.getElementById('searchcount').innerHTML = thing.replace(/\d+/, thenumber - 1);
},
error: function (exception) {
alert("error:" + JSON.stringify(exception));
console.log("error:" + JSON.stringify(exception));
}
});
I get the following error:
error:{"readyState":0,"responseText":"","status":0,"statusText":"error"}
Some help would be apreciated.
EDIT:
The call is a crossdomain, and i get the following message:
XMLHttpRequest cannot load https://"CAN'TSHOWTHIS"/FacetedSearchApi/DeleteStoredSearch. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin http://CAN'TSHOWTHIS.com' is therefore not allowed access.