0
I made a test application, where I point to a web api that’s online, the address of this api works and return the data if it’s posted to the browser URL, it does a GET. In the test application I have:
<Div>
<Select id="method">
<Option value="get"> GET </option>
<Option value="post"> POST </option>
<Option value="put"> PUT </option>
</Select>
<Input type="button" value="Experimente" onclick="sendRequest()" />
<Span id='value1'>(Resultado)</span>
</Div>
@section scripts {
<script>
// TODO: Replace with the URL of your WebService app
var serviceUrl = ‘enderecoapi';
function sendRequest() {
var method = $('#method').val();
$.ajax({
type: method,
url: serviceUrl
}).done(function (data) {
$('#value1').text(data);
}).error(function (jqXHR, textStatus, errorThrown) {
$('#value1').text(jqXHR.responseText || textStatus);
});
}
</script>
}
You’re not returning the data to me, I inspected the data and did not return error, only "XHR finished loading: GET"
I am not an expert on ASP.net @itasouza, but rather, the server (who serves) has to allow an action to be taken. The difference of running GET by Browser and not by Ajax is that Ajax does an Xmlhttprequest and this information goes in the request header. Therefore, the only elegant and correct way is the ASP application to allow Cross-Origin.
– BrTkCa
@Lucascosta, I’ll look it up
– Harry