Json extraction of data...
Json extraction of data...
when i do an ajax call to a dict: info i get:
{
"info[0][]":[
"6699",
"66",
"+3225341676",
"deskphone",
"0C:11:05:0D:75:9C",
"Akuvox",
"R15P"
],
"info[1][]":[
"6699",
"66",
"+3225341676",
"deskphone",
"0C:11:05:0D:75:9C",
"Akuvox",
"R15P"
],
"csrfmiddlewaretoken":[
"G6al1GeiznUPaWkrJ8RE4wfghqzaDziOkv3J8g03NP1DzHmS6iGyy1G1XlmYWUYT"
]
}
my code in javascript:
$('#submit_phones').click( function() {
var data = table.rows( { selected: true } ).data().toArray();
alert(data)
var URL = "{% url 'upload_devices' %}";
$.ajax({
type: "POST",
url: URL,
dataType: 'JSON',
data: {
info : data,
csrfmiddlewaretoken : '{{ csrf_token }}',
},
success : function(data) {
alert("Successfully sent the data to Django");
},
error : function(xhr,errmsg,err) {
alert("Could not send URL to Django. Error: " + xhr.status + ": " + xhr.responseText);
}
});
});
anyone has an idea how to add keys to the values ? or how to get rid of the [][] ?
This question has an accepted answers - jump to answer
Answers
See my reply in your other thread. The reason both are posted now is because the spam filter was a bit over zealous and blocked them,
Colin