Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
Pass data from JS to Python via Django

I want to send data from python to JS in Django. I successfully see the data in the response in the browser, but JS returns as empty string. What would be the reason?

trying to fetch information;

def XXX(request):
    message_id=request.POST.get('messageid')
    return render(request, 'XX.html')

sender;

    y = json.loads(response.text)
    ts = str(y["file"]["shares"]["public"]["XX"][0]["ts"])
    return render (request, 'problemduyurusucreate.html', {'ts':ts})

JS;

    <script type=text/javascript>
    function slacksil() {
  html2canvas(document.getElementById("main"), {
    letterRendering: 1,
    allowTaint: true,
    useCORS: true,})
  .then(function (canvas) {
  swal({
    title: "Emin misiniz?",
    text: "Duyuru Kanaldan Silinecek!",
    icon: "warning",
    buttons: true,
    dangerMode: true,})
  .then((willDelete) => {
  if (willDelete) {
    document.getElementById("result").src = canvas.toDataURL("image/png", 0.5);
    var deneme = "{{ ts }}";
    $.ajax({
    type: "POST",
    url: "{% url 'slacksilproblem' %}",
    data: { 
    "messageid": deneme,
    csrfmiddlewaretoken: '{{ csrf_token }}'}})
  swal({
    title: "Duyuru Kanaldan Silindi!",
      icon: "success",})} 
  else {
  swal("İşlem İptal Edildi!", {
    icon: "error",});}});
        })
        .catch((e) => {
            alert(e);
        }); 
}
  </script>

but I am displaying in my browser that I have successfully pulled the data enter image description here

first im sending post request to python for sending image after python script python send to html message timestamp id; enter image description here

then post requst to delete message with timestamp id, but its comes empty to python. But when I look at the answer in the browser, I see that the data is coming enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I solved the problem by sending the data to the cookie with python and retrieving the data from again python.

sender data to cookie ( x is my data );

    html = HttpResponse("<h1>TP</h1>")
    html.set_cookie('ts', x, max_age = None)
    return html

and fetch data in another fonc. like this;

message_id=request.COOKIES['ts']

finally delete cookie;

html.delete_cookie('ts','!') 
about 4 years ago · Juan Pablo Isaza 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda