I have this code from JQUERY:
$(document).ready(function() {
listarDetalle();
});
function listarDetalle(){
var accion="listar";
var URLprotocol = window.location.protocol;
$.ajax({
type: "POST",
url: URLprotocol+"//gestionweb/includes/php/procesoDetalle.php",
data: { "accion":accion},
dataType:'json',
error: function(){
alert("error petición ajax");
},
success: function(data){
console.log(data);
for (var i = 0; i < data.length; i++) {
var newRow =
"<tr>" +
"<td>" + data[i].idp + "</td>" +
"<td>" + data[i].nombre + "</td>"
"<td>" + data[i].marca + "</td>" +
"<td>" + data[i].cantidad + "</td>" +
"<td><input type='radio' id='"+data[i].idproducto+"' name='seleccion'/></td>"+
"</tr>";
$(newRow).appendTo("#ticket tbody");
} }
}).fail( function( jqXHR, textStatus, errorThrown ) {
if (jqXHR.status === 0) {
alert('Not connect: Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (textStatus === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (textStatus === 'timeout') {
alert('Time out error.');
} else if (textStatus === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error: ' + jqXHR.responseText);
}
});;
};
And I get this error:
Blocked Crossed Origin Request: The Same Source Policy does not allow you to read the remote resource in link . (Reason: the CORS request was rejected).
Try with:
dataType:'jsonp',
What I found on a website, but if I do that, it tells me that the script failed to load. I really do not know what to do. I attach google chrome images of the headings ... the address appears well let's say:
as you will see error 302 in processDetail.php as the resource was moved but I do not understand.
I'm calling from another script and everything is fine