• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

210
Vistas
Solicitud de JSONP angular de dominio cruzado a Python Bottle

Estoy tratando de hacer una solicitud JSONP entre dominios con AngularJS a Bottle, pero recibo un error.

Angular:

 // this angular code is on localhost:8888, so it's cross domain var URL = "http://localhost:8000/test"; URL = $sce.trustAsResourceUrl(URL); $http.jsonp(URL, {jsonpCallbackParam: 'callback'}) .then(function successCallback(response) { console.log(response); }, function errorCallback(error) { console.log(error); });

Botella:

 @route('/test') def test(): response.headers['Content-Type'] = 'application/json' return json.dumps({"random": "JSON"})

Error:

almost 3 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Debe devolver una aplicación JavaScript (función contenedora en este caso) no un objeto json. Este sitio le explica los conceptos básicos del manejo de JSONP .

 def jsonp(request, dictionary): if (request.query.callback): # wrap the dictionary in the callback parameter return "%s(%s)" % (request.query.callback, dictionary) return dictionary @route('/test') if (request.query.callback): response.content_type = "application/javascript" return jsonp(dict(success="It worked"))
almost 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda