Answer the question
In order to leave comments, you need to log in
How to convert received response from ajax to python array?
Hello, please tell me
there is a button, when pressed, ajax should work, send a request to the server and receive a response in the form
{
"ok":true,
"result":[
{
"update_id":377151451,
"chat":{
"id":-371111,
},
"date":1611956075,
}
},
{
"update_id":3771522,
"chat":{
"id":-379333
},
"date":1611956084,
]
}
}
]
}
$("#update_groups").click(function () {
$.ajax({
type: 'POST',
url: 'https://api.telegram.org/bot.../getUpdates',
dataType: 'json',
success: function (data) {
{#alert(data.result);#}
$.ajax({
type: 'POST',
url: 'http://127.0.0.1:8000/main/',
dataType: 'JSON',
data: data
});
}
});
})
if request.method == 'POST' and request.is_ajax():
form = request.POST
Answer the question
In order to leave comments, you need to log in
who needs this solution:
$.ajax({
type: 'POST',
url: '{% url 'send_message' %}',
datatype: "JSON",
data: JSON.stringify(data)
req = request.POST
update_groups = json.loads(req)
Can you google how to convert data to json in python?
https://www.google.com/search?q=python+json&oq=pyt...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question