
no recibo valor de respuesta en petición Ajax
Publicado por Tiago (10 intervenciones) el 01/04/2022 00:43:56
Buenos días, estoy teniendo un problema medio raro que nunca me había pasado,
estoy desarrollando una API Request en PHP, y le hago peticiones Ajax con JQuery, andaba todo perfecto hasta que quise que la API este en subdominios separados,
El problema que estoy teniendo es que al hacer la petición Ajax la API me devuelve un status code 200, pero no me devuelve ningún valor de respuesta..
dejo el código de prueba que es el que estoy usando para intentar hacerlo andar...
estos son los header
general:
Request URL: http://administracion.laordenweb.com/test.php?callback=jQuery36007798052715872681_1648766405446&_=1648766405447
Request Method: GET
Status Code: 200 OK
Remote Address: 168.197.50.235:80
Referrer Policy: no-referrer-when-downgrade
response headers:
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Origin: *
Connection: Keep-Alive
Content-Type: application/json
Date: Thu, 31 Mar 2022 22:40:05 GMT
Keep-Alive: timeout=5, max=100
Server: Apache
Transfer-Encoding: chunked
X-Powered-By: PHP/7.0.33
request headers:
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: es-US,es-419;q=0.9,es;q=0.8,en;q=0.7
Cache-Control: no-cache
Connection: keep-alive
Cookie: _ga=GA1.2.1747671626.1592499090; _gid=GA1.2.84761127.1648745376
Host: administracion.laordenweb.com
Pragma: no-cache
Referer: http://prod.laordenweb.com/
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
estoy desarrollando una API Request en PHP, y le hago peticiones Ajax con JQuery, andaba todo perfecto hasta que quise que la API este en subdominios separados,
El problema que estoy teniendo es que al hacer la petición Ajax la API me devuelve un status code 200, pero no me devuelve ningún valor de respuesta..
dejo el código de prueba que es el que estoy usando para intentar hacerlo andar...
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
header('Content-Type: application/json');
$jsonResp = array(
'error'=> array(),
'resultado' => true,
'respuesta' => array()
);
echo json_encode($jsonResp);
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<script src='jQuery.js'></script>
<script>
function agregarProducto() {
return $.ajax({
xhrFields: {
withCredentials: true
},
jsonp : 'callback',
method: 'POST',
contentType: "application/json; charset=utf-8",
url: 'http://administracion.laordenweb.com/test.php',
dataType: 'jsonp'
});
}
agregarProducto().done(function(a){console.log(a);});
</script>
</body>
</html>
estos son los header
general:
Request URL: http://administracion.laordenweb.com/test.php?callback=jQuery36007798052715872681_1648766405446&_=1648766405447
Request Method: GET
Status Code: 200 OK
Remote Address: 168.197.50.235:80
Referrer Policy: no-referrer-when-downgrade
response headers:
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Origin: *
Connection: Keep-Alive
Content-Type: application/json
Date: Thu, 31 Mar 2022 22:40:05 GMT
Keep-Alive: timeout=5, max=100
Server: Apache
Transfer-Encoding: chunked
X-Powered-By: PHP/7.0.33
request headers:
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: es-US,es-419;q=0.9,es;q=0.8,en;q=0.7
Cache-Control: no-cache
Connection: keep-alive
Cookie: _ga=GA1.2.1747671626.1592499090; _gid=GA1.2.84761127.1648745376
Host: administracion.laordenweb.com
Pragma: no-cache
Referer: http://prod.laordenweb.com/
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
Valora esta pregunta


0