Note: The following code is a personal summary, the wording may not be standardized.
Triggered when the button is clicked
$ ("A.submit"). Click (function () {
Because of the drag-and-drop, to get a few properties of the CSS after drag-and-drop generated is a label, so here gets the definition of a variable to get the label
var Tempdiv = $ ("#pTemplate label");
A new array is defined here, and the array in the loop is assigned to the new array
var full_array = new Array ();
For loop start, loop out the number of drag-generated label (TEMPDIV)
for (var i = 0; i < tempdiv.length; i++) {
Gets the ID of the label
var Labelidd = Tempdiv.eq (i). attr (' id ');
Defines the array within the loop that is used to pass in the CSS values to be obtained
var array = new Array ();
Pass the ID of all the labels into the array
Array.idarr = Labelidd;
Pass the text of all labels to the array
Array.namearr = Tempdiv.eq (i). text ();
Pass the CSS property width of all labels to the array
Array.widtharr = Tempdiv.eq (i). css (' width ');
Transmission height
Array.heightarr = Tempdiv.eq (i). css (' height ');
Value to pass left
Array.leftarr = Tempdiv.eq (i). Offset (). Left;
Pass Top value
Array.toparr = Tempdiv.eq (i). Offset (). Top;
Because the array, which is a loop once, generates one, so assign all of the values to the Full_array array defined by the loop.
Full_array.push (array);
Turn the Full_array array into JSON format
Json.stringify (Full_array);
}
Pass Full_array to the backstage with Ajax
$.ajax ({
Type: ' POST ',
URL: "/save_style.php",
' Stylearr ': Full_array, ' Styleid ': Styleid,
Success:function () {},
DataType: ' JSON '
});
});
JS/JQ ajax+ Array. Personal grooming