Trying to obtain the response from a GET services the ajax function always run into error section.
<!DOCTYPE html>
<!-- jquery -->
<link rel="stylesheet" href="jquery/jquery-ui.css">
<script src="jquery/jquery-1.11.1.min.js"></script>
<script src="jquery/jquery-ui.js"></script>
<!-- bootstrap -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">
<script src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
$.ajax(
{
url: "http://localhost:8080/POC-WebApplication/obtenerusuarios",
type: "GET",
dataType: "jsonp",
success: function(data, textStatus, jqXHR)
{
alert("success");
},
error: function(data, textStatus, jqXHR)
{
alert("FAIL!!!!\ndata: "+data+"\ntextStatus: "+textStatus+"\njqXHR: "+jqXHR);
}
});
</script>
When the browser executes the code I got this results:
- data: [object Object]
- textStatus: parserror
- jqXHR: Error: jQuery1111.....3111 was not called
I tried with dataType: "json" but I got this error in the chrome debug console:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
and the alerts print:
- data: [object Object]
- textStatus: error
- jqXHR: Error:
****EDITED****
I solved it using this chrome app: https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi
I encourage everyone with the same problem as me to use it.