How jquery transforms an array into a string to the server and processes _jquery

Source: Internet
Author: User
jquery transforms the array into a string and then spreads it to the server (jquery converts the array to a string, formatted like 1,2,3, speed, REWR)
Copy Code code as follows:

Define (function (Require, exports, module) {

var Notify = require (' common/bootstrap-notify ');

Module.exports = function ($element) {

$element. On (' click ', ' [data-role=batch-delete] ', function () {

var $btn = $ (this);
Name = $btn. Data (' name ');

var ids = [];
$element. Find (' [data-role=batch-item]:checked ']. each (function () {
Ids.push (This.value);
});

if (Ids.length = = 0) {
Notify.danger (' No ' + name selected ');
return;
}

if (!confirm (') would you like to remove the selected ' + ids.length + ' bar ' + name + ')? ')) {
return;
}

$element. Find ('. btn '). addclass (' disabled ');

Notify.info (' deleting ' + name + '), please wait a moment. ', 60);
var values=ids.tostring ();
$.post ($btn. Data (' URL '), {ids:values}, function () {
Window.location.reload ();
});

});

};

});

Receive a string from jquery, parse the array, and then convert it to the list collection
Copy Code code as follows:

/**
* Bulk Delete DMS.
/*
@RequestMapping (value = "/delete", method = {Requestmethod.get,requestmethod.post})
Public responseenti ty<ajaxpostresponse> Delete (HttpServletRequest request) {
///DMS ID list to be deleted
String messageids = Servletreque Stutils.getstringparameter (Request, "IDs", "");
String[] messagelist=messageids.tostring (). Split (",");
List<string> messageidlist = arrays.aslist (messagelist);//array converted to List
Logger.info ("------------" + Messageids);
Logger.info ("------------" +messagelist[0]);
try {
Boolean opstatus = Messagemanager.delete (messageidlist);
Logger.info ("Delete dms: opstatus={}", Opstatus);
return This.okresponse (opstatus);
} catch (Exception e) {
Logger.error ("exception occurred while adding DMS, Cause:", e);
Return This.errorresponse (E.getmessage ());
}
}

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.