JS/JQ ajax+ Array. Personal grooming

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.