S
S
semki0962016-03-25 15:54:16
PHP
semki096, 2016-03-25 15:54:16

How to turn html data into json array?

Here is the html

<div id="my-dropzone">
<span>img1.png</span>
<span>img2.png</span>
<span>img3.png</span>
</div>

This is how I get the names of the pictures.
var drop_images = $("#my-dropzone span").text();
And I send them to the database with Ajax. But it turns out like this img1.pngimg2.pngimg3.png And I need in the json array [{img1.png,img2.png,img3.png}] How to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-03-25
@semki096

var drop_images = $("#my-dropzone span").map(function(){return $(this).text()});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question